136 lines
4.8 KiB
C#
136 lines
4.8 KiB
C#
using Aurora;
|
|
using Aurora.Api;
|
|
using VisionCommon;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Windows;
|
|
using Aurora.Util.HislogPlus;
|
|
using Aurora.View;
|
|
|
|
namespace VisionUI.Setup {
|
|
/// <summary>
|
|
/// 센터 튜닝 로그 아이템
|
|
/// </summary>
|
|
public class CenterTuningLogItem : ICloneable {
|
|
/// <summary>시간</summary>
|
|
public string Time { get; set; }
|
|
/// <summary>현재 진행 횟수</summary>
|
|
public int CurrentCnt { get; set; }
|
|
/// <summary>얼라인 결과값 X</summary>
|
|
public double DeltaX { get; set; }
|
|
/// <summary>얼라인 결과값 Y</summary>
|
|
public double DeltaY { get; set; }
|
|
/// <summary>얼라인 결과값 T</summary>
|
|
public double DeltaT { get; set; }
|
|
|
|
/// <summary>
|
|
/// Clone (Copy)
|
|
/// </summary>
|
|
/// <returns>센터 튜닝 로그 아이템</returns>
|
|
public object Clone() {
|
|
return new CenterTuningLogItem() {
|
|
Time = this.Time,
|
|
CurrentCnt = this.CurrentCnt,
|
|
DeltaX = this.DeltaX,
|
|
DeltaY = this.DeltaY,
|
|
DeltaT = this.DeltaT
|
|
};
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 센터 튜닝 로그 아이템 매니저
|
|
/// </summary>
|
|
public class CenterTuningLogItemManager : ItemManagerBase {
|
|
private static readonly object _Lock = new object();
|
|
|
|
/// <summary>
|
|
/// 공정 시간을 포함한 센터 튜닝 로그 아이템으로 변환한다.
|
|
/// </summary>
|
|
/// <param name="subSysInfo">서브시스템 키 정보</param>
|
|
/// <param name="item">센터 튜닝 로그 아이템</param>
|
|
/// <returns>센터 튜닝 로그 아이템</returns>
|
|
public static CenterTuningLogItem GetCenterTuningLogItem(SubSysInfo subSysInfo, CenterTuningLogItem item) {
|
|
lock (_Lock) {
|
|
return new CenterTuningLogItem() {
|
|
Time = GetTimeStamp(subSysInfo, item),
|
|
CurrentCnt = item.CurrentCnt,
|
|
DeltaX = item.DeltaX,
|
|
DeltaY = item.DeltaY,
|
|
DeltaT = item.DeltaT
|
|
};
|
|
}
|
|
}
|
|
}
|
|
|
|
class CenterTuningLogViewModel : NotifyPropertyChangedBase {
|
|
private Logger Log = new Logger("CenterTuningLogViewModel");
|
|
private SubSysInfo _SubSysInfo;
|
|
private SubSysRecipe _SubSysRecipe;
|
|
private CsvManager _CsvManager = new CsvManager();
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
private DateTime selectedDate;
|
|
|
|
/// <summary>선택된 날짜</summary>
|
|
public DateTime SelectedDate { get => selectedDate; set { SetProperty(ref selectedDate, value); CalendarChanged(value); } }
|
|
|
|
private ObservableCollection<CenterTuningLogItem> _CenterTuningLogItems;
|
|
/// <summary>센터 튜닝 로그 아이템</summary>
|
|
public ObservableCollection<CenterTuningLogItem> CenterTuningLogItems {
|
|
get {
|
|
return _CenterTuningLogItems;
|
|
}
|
|
set {
|
|
_CenterTuningLogItems = value;
|
|
NotifyPropertyChanged("CenterTuningLogItems");
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 센터 튜닝 로그 뷰 모델
|
|
/// </summary>
|
|
/// <param name="subSysInfo">서브시스템 정보</param>
|
|
public CenterTuningLogViewModel(SubSysInfo subSysInfo) {
|
|
_SubSysInfo = subSysInfo;
|
|
_SubSysRecipe = VisionRecipeManager.GetSubSysRecipe(subSysInfo);
|
|
CenterTuningLogItems = new ObservableCollection<CenterTuningLogItem>();
|
|
SelectedDate = DateTime.Now.Date;
|
|
}
|
|
|
|
private void NotifyPropertyChanged(string propName) {
|
|
PropertyChanged?.Invoke(
|
|
this,
|
|
new PropertyChangedEventArgs(propName));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 현재 시간 기준으로 CSV 불러오기
|
|
/// </summary>
|
|
public void LoadCsvNow() {
|
|
DateTime dateTime = DateTime.Now;
|
|
LoadCsv(dateTime);
|
|
}
|
|
|
|
private void CalendarChanged(DateTime dateTime) {
|
|
LoadCsv(dateTime);
|
|
}
|
|
|
|
private void LoadCsv(DateTime dateTime) {
|
|
try {
|
|
CenterTuningLogItems.Clear();
|
|
List<CenterTuningLogItem> items = _CsvManager.LoadCsv<CenterTuningLogItem>(_SubSysInfo, dateTime, eSaveDataType.CenterTuning);
|
|
if (items != null) {
|
|
foreach (CenterTuningLogItem item in items) {
|
|
CenterTuningLogItems.Add(item);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception e) {
|
|
Log.FuncE(e.Message);
|
|
}
|
|
}
|
|
}
|
|
} |