/* * 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 { /// /// 얼라인 횟수 체크 /// public class AlignCountChecker { private AlignRecipe _AlignRecipe; private Logger _Logger; private int _CurrentAlignCount; private bool _RetryFlag = false; /// /// 생성자 /// /// 얼라인 레시피 public AlignCountChecker(AlignRecipe alignRecipe) { _Logger = new Logger("AlignCountChecker"); _AlignRecipe = alignRecipe; ResetAlignCount(); } /// /// 얼라인 횟수 초기화 /// public void Reset() { ResetAlignCount(); SetRetryFlag(false); } /// /// 현재 얼라인의 횟수를 Get한다 /// /// 얼라인 상태 /// 현재 얼라인 횟수 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; } } }