90 lines
2.4 KiB
C#
90 lines
2.4 KiB
C#
/*
|
|
* Copyright (c) 2025 LG Electronics Inc.
|
|
* SPDX-License-Identifier: LicenseRef-LGE-Proprietary
|
|
*/
|
|
using Aurora.Api;
|
|
using VisionCommon;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace VisionAligner {
|
|
/// <summary>
|
|
/// 얼라인 횟수 체크
|
|
/// </summary>
|
|
public class AlignCountChecker {
|
|
private AlignRecipe _AlignRecipe;
|
|
private Logger _Logger;
|
|
|
|
private int _CurrentAlignCount;
|
|
private bool _RetryFlag = false;
|
|
|
|
/// <summary>
|
|
/// 생성자
|
|
/// </summary>
|
|
/// <param name="alignRecipe">얼라인 레시피</param>
|
|
public AlignCountChecker(AlignRecipe alignRecipe) {
|
|
_Logger = new Logger("AlignCountChecker");
|
|
_AlignRecipe = alignRecipe;
|
|
|
|
ResetAlignCount();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 얼라인 횟수 초기화
|
|
/// </summary>
|
|
public void Reset() {
|
|
ResetAlignCount();
|
|
SetRetryFlag(false);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 현재 얼라인의 횟수를 Get한다
|
|
/// </summary>
|
|
/// <param name="status">얼라인 상태</param>
|
|
/// <returns>현재 얼라인 횟수</returns>
|
|
public int GetCurrentAlignCount(AlignStatus status) {
|
|
if (status == AlignStatus.OK ||
|
|
status == AlignStatus.ALIGN_LIMIT_OVER) {
|
|
if (!GetRetryFlag()) {
|
|
ResetAlignCount();
|
|
}
|
|
else {
|
|
SetRetryFlag(false);
|
|
}
|
|
}
|
|
else if (status == AlignStatus.RETRY && !GetRetryFlag()) {
|
|
ResetAlignCount();
|
|
SetRetryFlag(true);
|
|
}
|
|
else if (status == AlignStatus.RETRY_COUNT_OVER) {
|
|
var lastAlignCnt = ++_CurrentAlignCount;
|
|
ResetAlignCount();
|
|
|
|
return lastAlignCnt;
|
|
}
|
|
IncreaseAlignCount();
|
|
|
|
return _CurrentAlignCount;
|
|
}
|
|
|
|
private void IncreaseAlignCount() {
|
|
_CurrentAlignCount++;
|
|
}
|
|
|
|
private void ResetAlignCount() {
|
|
_CurrentAlignCount = 0;
|
|
}
|
|
|
|
private void SetRetryFlag(bool retryFlag) {
|
|
_RetryFlag = retryFlag;
|
|
}
|
|
|
|
private bool GetRetryFlag() {
|
|
return _RetryFlag;
|
|
}
|
|
}
|
|
}
|