86 lines
3.3 KiB
C#
86 lines
3.3 KiB
C#
/*
|
|
* Copyright (c) 2025 LG Electronics Inc.
|
|
* SPDX-License-Identifier: LicenseRef-LGE-Proprietary
|
|
*/
|
|
using Aurora.Api;
|
|
using Aurora.View;
|
|
using VisionCommon;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Reactive.Linq;
|
|
using System.Windows;
|
|
|
|
namespace VisionUI.Pattern {
|
|
/// <summary>
|
|
/// 바코드 로그 뷰 모델
|
|
/// </summary>
|
|
public class BcrLogViewModel : NotifyPropertyChangedBase {
|
|
private Logger _Logger = new Logger("BcrLogViewModel");
|
|
|
|
private ObservableCollection<BcrResultItem> bcrResultItems;
|
|
/// <summary>바코드 결과 아이템 컬렉션</summary>
|
|
public ObservableCollection<BcrResultItem> BcrResultItems { get => bcrResultItems; set => SetProperty(ref bcrResultItems, value); }
|
|
|
|
private string dislayName;
|
|
/// <summary>디스플레이 이름</summary>
|
|
public string DisplayName { get => dislayName; set => SetProperty(ref dislayName, value); }
|
|
|
|
private DateTime selectedDate;
|
|
/// <summary>선택 날짜</summary>
|
|
public DateTime SelectedDate { get => selectedDate; set { SetProperty(ref selectedDate, value); CalendarChanged(value); } }
|
|
|
|
private SubSysInfo _SubSysInfo;
|
|
private SubSysRecipe _SubSysRecipe;
|
|
private CsvManager _CsvManager = new CsvManager();
|
|
/// <summary>
|
|
/// 생성자
|
|
/// </summary>
|
|
/// <param name="subSysInfo">서브 시스템 정보</param>
|
|
public BcrLogViewModel(SubSysInfo subSysInfo) {
|
|
_SubSysInfo = subSysInfo;
|
|
_SubSysRecipe = VisionRecipeManager.GetSubSysRecipe(_SubSysInfo);
|
|
DisplayName = _SubSysInfo.SubSysName + " " + _SubSysRecipe.FovRecipes[0].CamRecipe.CamId;
|
|
BcrResultItems = new ObservableCollection<BcrResultItem>();
|
|
SelectedDate = DateTime.Now.Date;
|
|
|
|
SetObservable();
|
|
}
|
|
|
|
private void SetObservable() {
|
|
VisionEnv.AuroraEnv.EventObservable.AsObservable(VisionEventId.UPDATE_BCR_RESULT).
|
|
Where(x => x.From == _SubSysInfo.GetKey()).Subscribe(patternResult => UpdateBcrResult(patternResult));
|
|
}
|
|
/// <summary>
|
|
/// 바코드 결과 값 업데이트
|
|
/// </summary>
|
|
/// <param name="msg">이벤트 메세지</param>
|
|
public void UpdateBcrResult(EventMessage msg) {
|
|
Application.Current.Dispatcher.BeginInvoke(
|
|
new Action(() => {
|
|
BcrResultItems.Add(BcrResultItemManager.GetBcrResultItem(_SubSysInfo, msg.Param as PatternResult));
|
|
}));
|
|
}
|
|
|
|
private void CalendarChanged(DateTime dateTime) {
|
|
LoadCsv(dateTime);
|
|
}
|
|
|
|
private void LoadCsv(DateTime dateTime) {
|
|
try {
|
|
BcrResultItems?.Clear();
|
|
List<BcrResultItem> items =
|
|
_CsvManager.LoadCsv<BcrResultItem>(_SubSysInfo, dateTime, eSaveDataType.BCR);
|
|
if (items != null) { // 로드할 파일이 없으면 items가 null임.
|
|
foreach (BcrResultItem item in items) {
|
|
BcrResultItems.Add(item);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception e) {
|
|
_Logger.FuncE(e.Message);
|
|
}
|
|
}
|
|
}
|
|
}
|