- 오토런 시작 시 RCC 패턴 폴더 변경 감지 → B2506 ON, PLC ACK(B2409) 수신 시 OFF - 서브 패턴 1~10, 패턴 목록에 서브 썸네일 표시(행 내 좌우 스크롤) - 서브 패턴 등록 직후 활성화 OFF - 패턴 파일이 다른 프로그램에서 열려 있으면 삭제하지 않고 안내 - 현장 소스 반영: Train ROI 슬라이더, KS 조명 밝기 저장/적용, 조명 ID 분리, 스캔 후 카메라 라이브 재시작, 레시피 21 RCC NG 우회, 오토런 상태 판단
187 lines
7.8 KiB
C#
187 lines
7.8 KiB
C#
/*
|
|
* Copyright (c) 2025 LG Electronics Inc.
|
|
* SPDX-License-Identifier: LicenseRef-LGE-Proprietary
|
|
*/
|
|
using Aurora;
|
|
using Aurora.Api;
|
|
using System;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Collections.Generic;
|
|
using VisionCommon;
|
|
using VisionLight;
|
|
using VisionCommonUI;
|
|
using VisionCommonUI.Resources;
|
|
|
|
namespace VisionUI.Pattern {
|
|
/// <summary>
|
|
/// 패턴 리스트 뷰
|
|
/// PatternListView.xaml behind code
|
|
/// </summary>
|
|
public partial class PatternListView : UserControl {
|
|
private Logger _Logger = new Logger(typeof(PatternListView).Name);
|
|
private FovInfo _FovInfo;
|
|
private FovRecipe _FovRecipe;
|
|
private ContextMenu _ContextMenu_Root = new ContextMenu();
|
|
|
|
/// <summary>
|
|
/// 생성자
|
|
/// </summary>
|
|
/// <param name="fovInfo">fov 정보</param>
|
|
public PatternListView(FovInfo fovInfo) {
|
|
_FovInfo = fovInfo;
|
|
_FovRecipe = VisionRecipeManager.GetFovRecipe(fovInfo);
|
|
|
|
InitializeComponent();
|
|
AddContextMenu();
|
|
}
|
|
|
|
private void AddContextMenu() {
|
|
AddContextMenu_CopyPattern();
|
|
}
|
|
|
|
private void AddContextMenu_CopyPattern() {
|
|
// Copy Pattern
|
|
var menuItem_Copy = new MenuItem();
|
|
menuItem_Copy.Header = StrTokens.Copy;
|
|
|
|
// Unit
|
|
foreach (UnitInfo unitInfo in VisionRecipeManager.GetUnitInfos()) {
|
|
var menuItem_Unit = new MenuItem() {
|
|
Header = unitInfo.UnitName
|
|
};
|
|
// SubSys
|
|
foreach (SubSysInfo subSysInfo in VisionRecipeManager.GetSubSysInfos(unitInfo)) {
|
|
var menuItem_SubSys = new MenuItem() {
|
|
Header = subSysInfo.SubSysName
|
|
};
|
|
// Fov
|
|
foreach (FovInfo fovInfo in VisionRecipeManager.GetFovInfos(subSysInfo)) {
|
|
if (_FovInfo.Equals(fovInfo)) {
|
|
continue;
|
|
}
|
|
var menuItem_Fov = new MenuItem() {
|
|
Header = fovInfo.FovName,
|
|
CommandParameter = fovInfo
|
|
};
|
|
menuItem_Fov.Click += MenuItem_Fov_Click;
|
|
menuItem_SubSys.Items.Add(menuItem_Fov);
|
|
}
|
|
menuItem_Unit.Items.Add(menuItem_SubSys);
|
|
}
|
|
menuItem_Copy.Items.Add(menuItem_Unit);
|
|
}
|
|
|
|
_ContextMenu_Root.Items.Add(menuItem_Copy);
|
|
lbPatternList.ContextMenu = _ContextMenu_Root;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 현재 선택된 패턴을 다른 FOV로 복사
|
|
/// </summary>
|
|
private void MenuItem_Fov_Click(object sender, RoutedEventArgs e) {
|
|
try {
|
|
var patternId = lbPatternList.SelectedIndex;
|
|
var menuItem_Fov = sender as MenuItem;
|
|
var srcFovInfo = _FovInfo;
|
|
var srcFovRecipe = _FovRecipe;
|
|
var dstFovInfo = menuItem_Fov.CommandParameter as FovInfo;
|
|
var dstFovRecipe = VisionRecipeManager.GetFovRecipe(dstFovInfo);
|
|
|
|
PatternAgentBase srcPatternAgent = null;
|
|
PatternAgentBase dstPatternAgent = null;
|
|
PatternInfo dstPatternInfo = null;
|
|
PatternInfo srcPatternInfo = null;
|
|
|
|
srcPatternAgent = PatternAgentManager.GetAgent(srcFovInfo);
|
|
srcPatternInfo = srcPatternAgent.GetPatternInfo(srcFovInfo, patternId);
|
|
dstPatternAgent = PatternAgentManager.GetAgent(dstFovInfo);
|
|
dstPatternInfo = srcPatternInfo.Clone() as PatternInfo;
|
|
dstPatternInfo.PatternIndex = new PatternIndex(dstFovInfo.ToSubSysInfo(), dstFovInfo.FovId, patternId);
|
|
|
|
var result = MessageBoxResult.None;
|
|
if (dstPatternAgent.IsPatternExist(dstFovInfo, patternId)) {
|
|
result = MessageBoxUtil.ShowMessageBoxQuestion(string.Format(
|
|
StrTokens.MSG_Q_DeleteAndCopyPattern, patternId, dstFovInfo.FovName, dstFovInfo.SubSysName));
|
|
|
|
if (result == MessageBoxResult.Yes) {
|
|
dstPatternAgent.Remove(dstPatternInfo);
|
|
}
|
|
}
|
|
if (result != MessageBoxResult.No) {
|
|
CopyPatterns(srcPatternAgent, dstPatternAgent, srcPatternInfo, dstPatternInfo, dstFovRecipe);
|
|
}
|
|
}
|
|
catch (Exception ex) {
|
|
_Logger.FuncE(ex.Message);
|
|
}
|
|
}
|
|
|
|
private void ResetLightInfo(PatternInfo dstPatternInfo, FovRecipe dstFovRecipe) {
|
|
for (int i = 0; i < dstPatternInfo.LightInfo.LightParams.Count; i++) {
|
|
List<LightConfigInfo> lightConfigInfos = LightHub.Instance.GetLightConfigInfo(dstFovRecipe.CamRecipe.CamId);
|
|
if (lightConfigInfos?.Count > i) {
|
|
LightParam lightParam = dstPatternInfo.LightInfo.LightParams[i];
|
|
if (lightParam.LightId != lightConfigInfos[i].LightId) {
|
|
// 복사될 FOV의 조명 디바이스가 다를 경우, 해당 FOV의 조명 ID를 Set해준다.
|
|
lightParam.LightId = lightConfigInfos[i].LightId;
|
|
lightParam.Ch = lightConfigInfos[i].ChConfig.Ch;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 선택된 소스 패턴의 메인/서브 패턴들을 모두 복사한다.
|
|
/// </summary>
|
|
private void CopyPatterns(
|
|
PatternAgentBase srcPatternAgent, PatternAgentBase dstPatternAgent,
|
|
PatternInfo srcPatternInfo, PatternInfo dstPatternInfo,
|
|
FovRecipe dstFovRecipe) {
|
|
|
|
var srcPatternInfos = srcPatternAgent.GetMainSubPatterns(srcPatternInfo);
|
|
for (int i = 0; i < srcPatternInfos.Count; i++) {
|
|
var curSrcPatternInfo = srcPatternInfos[i];
|
|
var curDstPatternInfo = dstPatternInfo.Clone() as PatternInfo;
|
|
curDstPatternInfo.GetPatternIndex().PatternSubId = i;
|
|
|
|
srcPatternAgent.CopyPattern(curSrcPatternInfo, curDstPatternInfo);
|
|
dstPatternAgent.LoadPatterns();
|
|
ResetLightInfo(curDstPatternInfo, dstFovRecipe);
|
|
dstPatternAgent.Save(curDstPatternInfo);
|
|
}
|
|
|
|
MessageBoxUtil.ShowMessageBoxOk(StrTokens.MSG_O_CopyCompleted);
|
|
}
|
|
|
|
private void uc_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) {
|
|
bool isVisible = (bool)e.NewValue;
|
|
if (isVisible == true) {
|
|
UpdateVisionRecipes();
|
|
}
|
|
}
|
|
|
|
// 썸네일 행 안 : Shift + 휠은 좌우 스크롤, 그냥 휠은 목록 위아래 스크롤로 넘긴다.
|
|
private void svSubThumbnails_PreviewMouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e) {
|
|
if (!(sender is ScrollViewer scrollViewer)) {
|
|
return;
|
|
}
|
|
|
|
e.Handled = true;
|
|
if (System.Windows.Input.Keyboard.Modifiers == System.Windows.Input.ModifierKeys.Shift) {
|
|
scrollViewer.ScrollToHorizontalOffset(scrollViewer.HorizontalOffset - e.Delta);
|
|
return;
|
|
}
|
|
|
|
var parent = System.Windows.Media.VisualTreeHelper.GetParent(scrollViewer) as UIElement;
|
|
parent?.RaiseEvent(new System.Windows.Input.MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta) {
|
|
RoutedEvent = UIElement.MouseWheelEvent,
|
|
Source = scrollViewer
|
|
});
|
|
}
|
|
|
|
private void UpdateVisionRecipes() {
|
|
_FovRecipe = VisionRecipeManager.GetFovRecipe(_FovInfo);
|
|
}
|
|
}
|
|
} |