158 lines
7.1 KiB
C#
158 lines
7.1 KiB
C#
using Aurora.View;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Collections.Specialized;
|
|
using System.ComponentModel;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace VisionCommon {
|
|
public enum eSubSysId {
|
|
None = -1,
|
|
SubSys1 = 0, SubSys2, SubSys3, SubSys4, SubSys5,
|
|
SubSys6, SubSys7, SubSys8, SubSys9, SubSys10,
|
|
SubSys11, SubSys12, SubSys13, SubSys14, SubSys15,
|
|
SubSys16, SubSys17, SubSys18, SubSys19, SubSys20,
|
|
Max
|
|
}
|
|
|
|
public enum eSubSysType {
|
|
None = -1,
|
|
Align, // 얼라인 시스템 (Default)
|
|
Inspect, // 검사 시스템 (미지원)
|
|
Review // 공정 이미지 저장용 리뷰 시스템
|
|
}
|
|
|
|
public class SubSysRecipe : ICloneCopy<SubSysRecipe> {
|
|
public eSubSysId SubSysId { get; set; }
|
|
public string SubSysName { get; set; }
|
|
public eSubSysType SubSysType { get; set; } = eSubSysType.Align;
|
|
public ObservableCollection<FovRecipe> FovRecipes { get; set; } = new ObservableCollection<FovRecipe>();
|
|
public ObservableCollection<AlignRecipe> AlignRecipes { get; set; } = new ObservableCollection<AlignRecipe>();
|
|
public InspRecipe InspRecipe { get; set; } = new InspRecipe();
|
|
public CoordConvRecipe CoordConvRecipe { get; set; } = new CoordConvRecipe();
|
|
public DirectorRecipe TeachingDirectorRecipe { get; set; } = new DirectorRecipe();
|
|
public DirectorRecipe AlignDirectorRecipe { get; set; } = new DirectorRecipe();
|
|
public ProcRecipe ProcRecipe { get; set; } = new ProcRecipe();
|
|
public CalRecipe CalRecipe { get; set; } = new CalRecipe();
|
|
public SubSysSetupRecipe SubSysSetupRecipe { get; set; } = new SubSysSetupRecipe();
|
|
public LayoutRecipe LayoutRecipe { get; set; } = new LayoutRecipe();
|
|
|
|
public SubSysRecipe() {
|
|
FovRecipes.CollectionChanged += FovRecipes_CollectionChanged;
|
|
AlignRecipes.CollectionChanged += AlignRecipes_CollectionChanged;
|
|
}
|
|
|
|
#region FovRecipes CollectionChanged Event
|
|
private void FovRecipes_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) {
|
|
try {
|
|
var fovRecipes = sender as ObservableCollection<FovRecipe>;
|
|
|
|
if (e.Action == NotifyCollectionChangedAction.Add) {
|
|
var newFovReicpe = e.NewItems[0] as FovRecipe;
|
|
|
|
if (fovRecipes == null || fovRecipes.Count == 0) {
|
|
return;
|
|
}
|
|
else if (fovRecipes.Count > 4) {
|
|
//fovRecipes.RemoveAt(fovRecipes.Count - 1); // CollectionChanged 중에 데이터를 지울 수 없음.
|
|
MessageUtil.ShowErrorToast("The maximum count of FovRecipes cannot exceed 4.");
|
|
newFovReicpe.FovId = eFovId.None;
|
|
return;
|
|
}
|
|
else {
|
|
newFovReicpe.FovId = (eFovId)fovRecipes.Count - 1;
|
|
if (string.IsNullOrEmpty(newFovReicpe.FovName)) {
|
|
newFovReicpe.FovName = newFovReicpe.FovId.ToString();
|
|
}
|
|
}
|
|
}
|
|
else if (e.Action == NotifyCollectionChangedAction.Remove) {
|
|
int index = 0;
|
|
foreach (FovRecipe forRecipe in fovRecipes) {
|
|
if (index == (int)eFovId.Max) {
|
|
break;
|
|
}
|
|
forRecipe.FovId = (eFovId)index++;
|
|
if (string.IsNullOrEmpty(forRecipe.FovName) || forRecipe.FovName.Contains("Fov")) {
|
|
forRecipe.FovName = forRecipe.FovId.ToString();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex) {
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region AlignRecipes CollectionChanged Event
|
|
private void AlignRecipes_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) {
|
|
try {
|
|
var alignRecipes = sender as ObservableCollection<AlignRecipe>;
|
|
|
|
if (e.Action == NotifyCollectionChangedAction.Add) {
|
|
var newAlignReicpe = e.NewItems[0] as AlignRecipe;
|
|
|
|
if (alignRecipes == null || alignRecipes.Count == 0) {
|
|
return;
|
|
}
|
|
else if (alignRecipes.Count > 5) {
|
|
//alignRecipes.RemoveAt(alignRecipes.Count - 1); // CollectionChanged 중에 데이터를 지울 수 없음.
|
|
MessageUtil.ShowErrorToast("The maximum count of AlignRecipes cannot exceed 5.");
|
|
newAlignReicpe.AlignId = eAlignId.None;
|
|
return;
|
|
}
|
|
else {
|
|
newAlignReicpe.AlignId = (eAlignId)alignRecipes.Count - 1;
|
|
if (string.IsNullOrEmpty(newAlignReicpe.AlignName)) {
|
|
newAlignReicpe.AlignName = newAlignReicpe.AlignId.ToString();
|
|
}
|
|
}
|
|
}
|
|
else if (e.Action == NotifyCollectionChangedAction.Remove) {
|
|
int index = 0;
|
|
foreach (AlignRecipe alignRecipe in alignRecipes) {
|
|
if (index == (int)eAlignId.Max) {
|
|
break;
|
|
}
|
|
alignRecipe.AlignId = (eAlignId)index++;
|
|
if (string.IsNullOrEmpty(alignRecipe.AlignName) || alignRecipe.AlignName.Contains("Align")) {
|
|
alignRecipe.AlignName = alignRecipe.AlignId.ToString();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex) {
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
public SubSysRecipe Clone() {
|
|
return ((ICloneable)this).Clone() as SubSysRecipe;
|
|
}
|
|
|
|
object ICloneable.Clone() {
|
|
var cloneObj = new SubSysRecipe();
|
|
CopyTo(cloneObj);
|
|
return cloneObj;
|
|
}
|
|
|
|
public void CopyTo(SubSysRecipe target) {
|
|
target.SubSysId = this.SubSysId;
|
|
target.SubSysName = this.SubSysName;
|
|
target.SubSysType = this.SubSysType;
|
|
target.FovRecipes = new ObservableCollection<FovRecipe>(this.FovRecipes.Select(x => x.Clone()).ToList());
|
|
target.AlignRecipes = new ObservableCollection<AlignRecipe>(this.AlignRecipes.Select(x => x.Clone()).ToList());
|
|
target.InspRecipe = this.InspRecipe.Clone();
|
|
target.CoordConvRecipe = this.CoordConvRecipe.Clone();
|
|
target.TeachingDirectorRecipe = this.TeachingDirectorRecipe.Clone();
|
|
target.AlignDirectorRecipe = this.AlignDirectorRecipe.Clone();
|
|
target.ProcRecipe = this.ProcRecipe.Clone();
|
|
target.CalRecipe = this.CalRecipe.Clone();
|
|
target.SubSysSetupRecipe = this.SubSysSetupRecipe.Clone();
|
|
target.LayoutRecipe = this.LayoutRecipe.Clone();
|
|
}
|
|
}
|
|
} |