using System; using System.Collections.Generic; using System.ComponentModel; using System.Runtime.CompilerServices; using VisionAligner; using VisionCommon; namespace VisionSequence.Setup { /// /// 캘리브레이션 플랜의 아이템 /// public class PlanItem : INotifyPropertyChanged { /// 프로퍼티 변경 이벤트 핸들러 public event PropertyChangedEventHandler PropertyChanged; #region Calibration Binding Properties /// FOV ID public int FovId { get; set; } /// 플랜아이템의 스텝 번호 public string Step { get; set; } /// 플랜아이템의 캘리브레이션 목적 public string Purpose { get; set; } /// 플랜아이템의 축과 방향 public string Target { get; set; } /// 플랜아이템의 모터 이동 목적 public string Action { get; set; } /// X축 상대위치 이동량 public string X { get; set; } /// Y축 상대위치 이동량 public string Y { get; set; } /// T축 상대위치 회전량 public string T { get; set; } private string _imagePosX; /// 캘리브레이션 패턴 검출 이미지 좌표X public string ImagePosX { get { return _imagePosX; } set { _imagePosX = value; OnPropertyChanged("ImagePosX"); } } private string _imagePosY; /// 캘리브레이션 패턴 검출 이미지 좌표Y public string ImagePosY { get { return _imagePosY; } set { _imagePosY = value; OnPropertyChanged("ImagePosY"); } } private string _staticPosX; /// 캘리브레이션 패턴 검출 자재 좌표X public string StaticPosX { get { return _staticPosX; } set { _staticPosX = value; OnPropertyChanged("StaticPosX"); } } private string _staticPosY; /// 캘리브레이션 패턴 검출 자재 좌표Y public string StaticPosY { get { return _staticPosY; } set { _staticPosY = value; OnPropertyChanged("StaticPosY"); } } private string _resultT; /// 캘리브레이션 패턴 검출 T public string ResultT { get { return _resultT; } set { _resultT = value; OnPropertyChanged("ResultT"); } } #endregion /// /// 생성자 /// /// 플랜아이템의 스텝 번호 /// 플랜아이템의 캘리브레이션 목적 /// 플랜아이템의 축과 방향 /// 플랜아이템의 모터 이동 목적 /// X축 상대위치 이동량 /// Y축 상대위치 이동량 /// T축 상대위치 회전량 public PlanItem(string step, string purpose, string target, string action, string x, string y, string t) { FovId = -1; Step = step; Purpose = purpose; Target = target; Action = action; X = x; Y = y; T = t; } /// /// 생성자 /// public PlanItem() { } /// /// 복제(Deep Copy) /// /// 플랜 아이템 public PlanItem Clone() { return new PlanItem() { FovId = this.FovId, Step = this.Step, Purpose = this.Purpose, Target = this.Target, Action = this.Action, X = this.X, Y = this.Y, T = this.T, ImagePosX = this.ImagePosX, ImagePosY = this.ImagePosY, StaticPosX = this.StaticPosX, StaticPosY = this.StaticPosY, ResultT = this.ResultT, }; } protected void OnPropertyChanged([CallerMemberName] string propertyName = null) { if (string.IsNullOrEmpty(propertyName)) { return; } PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } } /// /// 캘리브레이션 결과의 아이템 /// public class CalResultItem : ICloneable { /// 공정 수행 시간 public string Time { get; set; } /// FOV ID public int FovId { get; set; } /// 플랜아이템의 스텝 번호 public string Step { get; set; } /// 플랜아이템의 캘리브레이션 목적 public string Purpose { get; set; } /// 플랜아이템의 축과 방향 public string Target { get; set; } /// 플랜아이템의 모터 이동 목적 public string Action { get; set; } /// X축 상대위치 이동량 public string X { get; set; } /// Y축 상대위치 이동량 public string Y { get; set; } /// T축 상대위치 회전량 public string T { get; set; } /// 캘리브레이션 패턴 검출 이미지 좌표X public string ImagePosX { get; set; } /// 캘리브레이션 패턴 검출 이미지 좌표Y public string ImagePosY { get; set; } /// 캘리브레이션 패턴 검출 자재 좌표X public string StaticPosX { get; set; } /// 캘리브레이션 패턴 검출 자재 좌표Y public string StaticPosY { get; set; } /// 캘리브레이션 패턴 검출 T public string ResultT { get; set; } /// /// Clone (Deep Copy) /// /// CalResultItem public object Clone() { return new CalResultItem() { Time = this.Time, FovId = this.FovId, Step = this.Step, Purpose = this.Purpose, Target = this.Target, Action = this.Action, X = this.X, Y = this.Y, T = this.T, ImagePosX = this.ImagePosX, ImagePosY = this.ImagePosY, StaticPosX = this.StaticPosX, StaticPosY = this.StaticPosY, ResultT = this.ResultT, }; } } /// /// Calibration 아이템 항목 매니저 /// public class CalItemManager : ItemManagerBase { private static readonly object _Lock = new object(); /// /// Calibration 아이템 항목을 Get한다 /// /// 서브 시스템 정보 /// 플랜 아이템 /// Calibration 아이템 항목 public static CalResultItem GetCalItem(SubSysInfo subSysInfo, PlanItem planItem) { lock (_Lock) { return new CalResultItem() { Time = GetTimeStamp(subSysInfo, planItem), FovId = planItem.FovId, Step = planItem.Step, Purpose = planItem.Purpose, Target = planItem.Target, Action = planItem.Action, X = planItem.X, Y = planItem.Y, T = planItem.T, ImagePosX = planItem.ImagePosX, ImagePosY = planItem.ImagePosY, StaticPosX = planItem.StaticPosX, StaticPosY = planItem.StaticPosY, ResultT = planItem.ResultT, }; } } public static PlanItem CalItemToPlanItem(CalResultItem calResultItem) { return new PlanItem() { FovId = calResultItem.FovId, Step = calResultItem.Step, Purpose = calResultItem.Purpose, Target = calResultItem.Target, Action = calResultItem.Action, X = calResultItem.X, Y = calResultItem.Y, T = calResultItem.T, ImagePosX = calResultItem.ImagePosX, ImagePosY = calResultItem.ImagePosY, StaticPosX = calResultItem.StaticPosX, StaticPosY = calResultItem.StaticPosY, ResultT = calResultItem.ResultT, }; } } }