117 lines
4.3 KiB
C#
117 lines
4.3 KiB
C#
/*
|
|
* Copyright (c) 2025 LG Electronics Inc.
|
|
* SPDX-License-Identifier: LicenseRef-LGE-Proprietary
|
|
*/
|
|
using Aurora;
|
|
using Aurora.Api;
|
|
using Aurora.Api.Devices;
|
|
using Aurora.View;
|
|
using VisionCommon;
|
|
using System;
|
|
using System.Windows;
|
|
using System.Windows.Input;
|
|
using VisionSequence.Setup;
|
|
using VisionCommonUI;
|
|
using VisionCommonUI.Resources;
|
|
|
|
namespace VisionUI.Setup {
|
|
/// <summary>
|
|
/// 센터 튜닝 세팅 뷰 모델
|
|
/// </summary>
|
|
class CenterTuningSettingViewModel : NotifyPropertyChangedBase, IUpdateRecipe {
|
|
private SubSysInfo _SubSysInfo;
|
|
private SubSysRecipe _SubSysRecipe;
|
|
|
|
private ISequence _Seq;
|
|
/// <summary>얼라인 델타 처리 이벤트 핸들러</summary>
|
|
public event EventHandler<Position> AlignDelta;
|
|
/// <summary>시퀀스 시작 이벤트 핸들러</summary>
|
|
public event EventHandler SequenceStart;
|
|
|
|
private CenterTuningRecipe _CenterTuningRecipe;
|
|
|
|
/// <summary>센터 튜닝 레시피</summary>
|
|
public CenterTuningRecipe CenterTuningRecipe { get => _CenterTuningRecipe; set => SetProperty(ref _CenterTuningRecipe, value); }
|
|
|
|
#region ButtonCommand
|
|
public ICommand ButtonCommandStart { get; set; }
|
|
public ICommand ButtonCommandCancel { get; set; }
|
|
public ICommand ButtonCommandSave { get; set; }
|
|
#endregion
|
|
/// <summary>
|
|
/// 생성자
|
|
/// </summary>
|
|
/// <param name="subSysInfo">서브 시스템 정보</param>
|
|
public CenterTuningSettingViewModel(SubSysInfo subSysInfo) {
|
|
_SubSysInfo = subSysInfo;
|
|
_SubSysRecipe = VisionRecipeManager.GetSubSysRecipe(subSysInfo);
|
|
|
|
ButtonCommandStart = new DelegateCommand(new Action<object>(DoStart));
|
|
ButtonCommandCancel = new DelegateCommand(new Action<object>(DoCancel));
|
|
ButtonCommandSave = new DelegateCommand(new Action<object>(DoSave));
|
|
}
|
|
/// <summary>
|
|
/// 시작
|
|
/// </summary>
|
|
/// <param name="obj">null</param>
|
|
public void DoStart(object obj) {
|
|
if (CenterTuningRecipe.MaxCnt < 1) {
|
|
MessageBoxUtil.ShowMessageBoxWarning(
|
|
string.Format(StrTokens.MSG_W_NumberUnderMinFormat, "MaxCnt", 1));
|
|
return;
|
|
}
|
|
else if (CenterTuningRecipe.MaxCnt > 30) {
|
|
MessageBoxUtil.ShowMessageBoxWarning(
|
|
string.Format(StrTokens.MSG_W_NumberOverMaxFormat, "MaxCnt", 30));
|
|
return;
|
|
}
|
|
|
|
_Seq = Application.Current.AuroraEnv().SequenceEntry[VisionKeys.CenterTuningSeqKey];
|
|
var param = new SetupSeqParams_CenterTuning(_SubSysInfo, CenterTuningRecipe, eDisplayType.CenterTuning);
|
|
param.CallBackAlignDelta = AddAlignDelta;
|
|
_Seq.Start(param, OnSeqCompleted);
|
|
SequenceStart.Invoke(this, null);
|
|
}
|
|
/// <summary>
|
|
/// 취소
|
|
/// </summary>
|
|
/// <param name="obj">null</param>
|
|
public void DoCancel(object obj) {
|
|
_Seq?.Stop();
|
|
//CancelSequence.Invoke(this, new EventArgs());
|
|
}
|
|
/// <summary>
|
|
/// 저장
|
|
/// </summary>
|
|
/// <param name="obj">null</param>
|
|
public void DoSave(object obj) {
|
|
UpdateRecipeFromUI();
|
|
RecipeFileManager.SaveVisionRecipe();
|
|
}
|
|
|
|
private void OnSeqCompleted(SequenceActionResult seqResult) {
|
|
int currentCnt = (int)seqResult.Param;
|
|
VisionEnv.AuroraEnv.EventPublisher.Publish(
|
|
new EventMessage(_SubSysInfo.SubSysName, VisionEventId.NOTIFY_CENTERTUNING_COMPLETED, currentCnt));
|
|
}
|
|
|
|
private void AddAlignDelta(Position position) {
|
|
AlignDelta.Invoke(this, position);
|
|
}
|
|
|
|
public void RefreshVisionRecipes() {
|
|
_SubSysRecipe = VisionRecipeManager.GetSubSysRecipe(_SubSysInfo);
|
|
}
|
|
|
|
public void UpdateRecipeFromFile() {
|
|
var centerTuningRecipe = VisionRecipeManager.GetCenterTuningRecipe(_SubSysInfo);
|
|
CenterTuningRecipe = centerTuningRecipe?.Clone();
|
|
}
|
|
|
|
public void UpdateRecipeFromUI() {
|
|
var centerTuningRecipe = VisionRecipeManager.GetCenterTuningRecipe(_SubSysInfo);
|
|
CenterTuningRecipe?.CopyTo(centerTuningRecipe);
|
|
}
|
|
}
|
|
}
|