using System;
using System.Collections.Generic;
using System.Linq;
using Aurora;
using System.Reactive.Linq;
using System.Windows;
using Aurora.Api;
using System.Collections.ObjectModel;
using System.Windows.Input;
using Aurora.View;
using VisionCommon;
using VisionSequence.Setup;
using VisionCommonUI;
using VisionCommonUI.Resources;
using VisionSequence.Aligner;
namespace VisionUI.Setup {
///
/// 비전 반복 View Model
///
public class VisionRepeatViewModel : Aurora.View.NotifyPropertyChangedBase, IUpdateRecipe {
private Logger _Logger;
private ISequence _Seq;
private FovInfo _FovInfo;
private FovRecipe _FovRecipe;
private CsvManager _CsvManager = new CsvManager();
private VisionRepeatRecipe _VisionRepeatRecipe;
///
/// 비전 반복도 측정 레시피
///
public VisionRepeatRecipe VisionRepeatRecipe { get => _VisionRepeatRecipe; set => SetProperty(ref _VisionRepeatRecipe, value); }
private int _count;
/// 반복 횟수
public int RepeatCount { get => _count; set => SetProperty(ref _count, value); }
private bool _enalbed;
/// 활성화
public bool Enabled { get => _enalbed; set => SetProperty(ref _enalbed, value); }
/// 비전 반복도 로그 아이템 리스트
public ObservableCollection VisionRepeatLogItems { get; set; } = new ObservableCollection();
private bool _isShapeModelFinder;
/// 패턴 종류가 Shape인 여부
public bool IsShapeModelFinder {
get => _isShapeModelFinder;
set {
SetProperty(ref _isShapeModelFinder, value);
NotifyPropertyChanged(nameof(IsShapeModelFinder));
}
}
private DateTime selectedDate;
/// 선택한 날짜
public DateTime SelectedDate { get => selectedDate; set { SetProperty(ref selectedDate, value); CalendarChanged(value); } }
private PatternInfo _selectedPatternInfo;
public PatternInfo SelectedPatternInfo { get => _selectedPatternInfo; set => SetProperty(ref _selectedPatternInfo, value); }
#region Image Pos Binding Properties
private double _meanX_I;
/// 평균 X (이미지 좌표)
public double MeanX_I { get => _meanX_I; set => SetProperty(ref _meanX_I, value); }
private double _meanY_I;
/// 평균 Y (이미지 좌표)
public double MeanY_I { get => _meanY_I; set => SetProperty(ref _meanY_I, value); }
private double _sdX_I;
/// SdX (이미지 좌표)
public double SdX_I { get => _sdX_I; set => SetProperty(ref _sdX_I, value); }
private double _sdY_I;
/// SdY (이미지 좌표)
public double SdY_I { get => _sdY_I; set => SetProperty(ref _sdY_I, value); }
private double _minX_I;
/// 최소값 X (이미지 좌표)
public double MinX_I { get => _minX_I; set => SetProperty(ref _minX_I, value); }
private double _minY_I;
/// 최소값 Y (이미지 좌표)
public double MinY_I { get => _minY_I; set => SetProperty(ref _minY_I, value); }
private double _maxX_I;
/// 최댓값 X (이미지 좌표)
public double MaxX_I { get => _maxX_I; set => SetProperty(ref _maxX_I, value); }
private double _maxY_I;
/// 최댓값 Y (이미지 좌표)
public double MaxY_I { get => _maxY_I; set => SetProperty(ref _maxY_I, value); }
private double _rangeX_I;
/// 범위 X (이미지 좌표)
public double RangeX_I { get => _rangeX_I; set => SetProperty(ref _rangeX_I, value); }
private double _rangeY_I;
/// 범위 Y (이미지 좌표)
public double RangeY_I { get => _rangeY_I; set => SetProperty(ref _rangeY_I, value); }
#endregion
#region Motion Pos Binding Properties
/// 반복도 로그 아이템리스트 (모터 좌표)
private double _meanX_S;
/// 평균 X (모터 좌표)
public double MeanX_S { get => _meanX_S; set => SetProperty(ref _meanX_S, value); }
private double _meanY_S;
/// 평균 Y (모터 좌표)
public double MeanY_S { get => _meanY_S; set => SetProperty(ref _meanY_S, value); }
private double _sdX_S;
/// SdX (모터 좌표)
public double SdX_S { get => _sdX_S; set => SetProperty(ref _sdX_S, value); }
private double _sdY_S;
/// SdY (모터 좌표)
public double SdY_S { get => _sdY_S; set => SetProperty(ref _sdY_S, value); }
private double _minX_S;
/// 최소값 X (모터 좌표)
public double MinX_S { get => _minX_S; set => SetProperty(ref _minX_S, value); }
private double _minY_S;
/// 최소값 Y (모터 좌표)
public double MinY_S { get => _minY_S; set => SetProperty(ref _minY_S, value); }
private double _maxX_S;
/// 최댓값 X (모터 좌표)
public double MaxX_S { get => _maxX_S; set => SetProperty(ref _maxX_S, value); }
private double _maxY_S;
/// 최댓값 Y (모터 좌표)
public double MaxY_S { get => _maxY_S; set => SetProperty(ref _maxY_S, value); }
private double _rangeX_S;
/// 범위 X (모터 좌표)
public double RangeX_S { get => _rangeX_S; set => SetProperty(ref _rangeX_S, value); }
private double _rangeY_S;
/// 범위 Y (모터 좌표)
public double RangeY_S { get => _rangeY_S; set => SetProperty(ref _rangeY_S, value); }
#endregion
#region Button Commands
public ICommand ButtonCommandStart { get; set; }
public ICommand ButtonCommandStartDynamic { get; set; }
public ICommand ButtonCommandCancel { get; set; }
public ICommand ButtonCommandSave { get; set; }
public ICommand ButtonCommandLog { get; set; }
#endregion
///
/// 생성자
///
/// Fov 정보
public VisionRepeatViewModel(FovInfo fovInfo) {
_FovInfo = fovInfo;
_FovRecipe = VisionRecipeManager.GetFovRecipe(fovInfo);
_Logger = new Logger(string.Format("VisionRepeatViewModel[{0}]", fovInfo.SubSysName));
ButtonCommandStart = new DelegateCommand(new Action