307 lines
12 KiB
C#
307 lines
12 KiB
C#
/*
|
|
* Copyright (c) 2025 LG Electronics Inc.
|
|
* SPDX-License-Identifier: LicenseRef-LGE-Proprietary
|
|
*/
|
|
using Aurora.Api;
|
|
using Aurora.Api.Devices;
|
|
using VisionCommon;
|
|
using VisionSequence.Pattern;
|
|
using VisionAligner;
|
|
using Hermes;
|
|
using VisionDirector;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace VisionSequence.Aligner {
|
|
/// <summary>
|
|
/// 얼라인 서브시퀀스 파라미터
|
|
/// </summary>
|
|
public class AlignSubSeqParams : SeqParamsBase {
|
|
/// <summary>얼라인 키 정보</summary>
|
|
public AlignInfo AlignInfo { get; set; }
|
|
/// <summary>FOV별로 이동시킬 절대위치</summary>
|
|
public Dictionary<eFovId, Position> FovPositions { get; set; }
|
|
/// <summary>메인 화면 타입</summary>
|
|
public eDisplayType DisplayType { get; set; }
|
|
|
|
/// <summary>
|
|
/// 얼라인 서브시퀀스 파라미터를 얻어온다.
|
|
/// </summary>
|
|
/// <param name="displayType">메인 화면 타입</param>
|
|
/// <param name="alignInfo">얼라인 키 정보</param>
|
|
/// <param name="fovPositions">FOV별로 이동시킬 절대위치. null일 경우, 자동으로 Adapter에 정의된 티칭위치로 이동</param>
|
|
public AlignSubSeqParams(
|
|
AlignInfo alignInfo,
|
|
Dictionary<eFovId, Position> fovPositions = null,
|
|
eDisplayType displayType = eDisplayType.Main_1,
|
|
eSeqMode seqMode = eSeqMode.Auto) : base(seqMode) {
|
|
|
|
this.AlignInfo = alignInfo;
|
|
this.DisplayType = displayType;
|
|
this.FovPositions = fovPositions;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 얼라인 서브시퀀스
|
|
/// </summary>
|
|
public class AlignSubSeq : SubSeqBase {
|
|
private readonly Logger LOG = new Logger(typeof(AlignSubSeq).Name);
|
|
|
|
private AlignRecipe _AlignRecipe;
|
|
private AlignSubSeqParams _Params;
|
|
|
|
#region Sequence Id
|
|
private const string SEQ_ID_INIT = "INIT";
|
|
private const string SEQ_ID_SELECT_ALIGN_SEQ = "SELECT_ALIGN_SEQ";
|
|
private const string SEQ_ID_SELECT_NG = "SELECT_NG";
|
|
|
|
// AlignSeq_C1_F1_M2C
|
|
private const string SEQ_ID_SET_ALIGN_SEQ_PARAMS_C1_F1_M2C = "SET_ALIGN_SEQ_PARAMS_C1_F1_M2C";
|
|
private const string SEQ_ID_ALIGN_SEQ_C1_F1_M2C = "ALIGN_SEQ_C1_F1_M2C";
|
|
|
|
// AlignSeq_C1_F1_M2R
|
|
private const string SEQ_ID_SET_ALIGN_SEQ_PARAMS_C1_F1_M2R = "SET_ALIGN_SEQ_PARAMS_C1_F1_M2R";
|
|
private const string SEQ_ID_ALIGN_SEQ_C1_F1_M2R = "ALIGN_SEQ_C1_F1_M2R";
|
|
|
|
// AlignSeq_C1_FN_MV
|
|
private const string SEQ_ID_SET_ALIGN_SEQ_PARAMS_C1_FN_MV = "SET_ALIGN_SEQ_PARAMS_C1_FN_MV";
|
|
private const string SEQ_ID_ALIGN_SEQ_C1_FN_MV = "ALIGN_SEQ_C1_FN_MV";
|
|
|
|
// AlignSeq_C2_F2
|
|
private const string SEQ_ID_SET_ALIGN_SEQ_PARAMS_C2_F2 = "SET_ALIGN_SEQ_PARAMS_C2_F2";
|
|
private const string SEQ_ID_ALIGN_SEQ_C2_F2 = "ALIGN_SEQ_C2_F2";
|
|
|
|
// AlignSeq_C2_F4_MV
|
|
private const string SEQ_ID_SET_ALIGN_SEQ_PARAMS_C2_F4_MV = "SET_ALIGN_SEQ_PARAMS_C2_F4_MV";
|
|
private const string SEQ_ID_ALIGN_SEQ_C2_F4_MV = "ALIGN_SEQ_C2_F4_MV";
|
|
|
|
// AlignSeq_C4_F4
|
|
private const string SEQ_ID_SET_ALIGN_SEQ_PARAMS_C4_F4 = "SET_ALIGN_SEQ_PARAMS_C4_F4";
|
|
private const string SEQ_ID_ALIGN_SEQ_C4_F4 = "ALIGN_SEQ_C4_F4";
|
|
|
|
private const string SEQ_ID_SEQ_COMPLETE = "SEQ_COMPLETE";
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 생성자
|
|
/// </summary>
|
|
public AlignSubSeq() {
|
|
}
|
|
|
|
private void SetActions(SequenceBuilder sb) {
|
|
SequenceBuilder alignSeqBuilder_C1_F1_M2C = SubSeqManager.CreateSubSeqBuilder(new AlignSeq_C1_F1_M2C(), "AlignSeq_C1_F1_M2C");
|
|
SequenceBuilder alignSeqBuilder_C1_F1_M2R = SubSeqManager.CreateSubSeqBuilder(new AlignSeq_C1_F1_M2R(), "AlignSeq_C1_F1_M2R");
|
|
SequenceBuilder alignSeqBuilder_C1_FN_MV = SubSeqManager.CreateSubSeqBuilder(new AlignSeq_C1_FN_MV(), "AlignSeq_C1_FN_MV");
|
|
SequenceBuilder alignSeqBuilder_C2_F2 = SubSeqManager.CreateSubSeqBuilder(new AlignSeq_C2_F2(), "AlignSeq_C2_F2");
|
|
SequenceBuilder alignSeqBuilder_C2_F4_MV = SubSeqManager.CreateSubSeqBuilder(new AlignSeq_C2_F4_MV(), "AlignSeq_C2_F4_MV");
|
|
SequenceBuilder alignSeqBuilder_C4_F4 = SubSeqManager.CreateSubSeqBuilder(new AlignSeq_C4_F4(), "AlignSeq_C4_F4");
|
|
|
|
sb.AddAction(SEQ_ID_INIT, Init);
|
|
sb.AddDecision(SEQ_ID_SELECT_ALIGN_SEQ, SelectAlignSeq);
|
|
sb.AddAction(SEQ_ID_SELECT_NG, SelectNG);
|
|
|
|
// AlignSeq_C1_F1_M2C
|
|
sb.AddAction(SEQ_ID_SET_ALIGN_SEQ_PARAMS_C1_F1_M2C, SetAlignSeqParams);
|
|
sb.AddSubsequence(SEQ_ID_ALIGN_SEQ_C1_F1_M2C, alignSeqBuilder_C1_F1_M2C);
|
|
|
|
// AlignSeq_C1_F1_M2R
|
|
sb.AddAction(SEQ_ID_SET_ALIGN_SEQ_PARAMS_C1_F1_M2R, SetAlignSeqParams);
|
|
sb.AddSubsequence(SEQ_ID_ALIGN_SEQ_C1_F1_M2R, alignSeqBuilder_C1_F1_M2R);
|
|
|
|
// AlignSeq_C1_FN_MV
|
|
sb.AddAction(SEQ_ID_SET_ALIGN_SEQ_PARAMS_C1_FN_MV, SetAlignSeqParams);
|
|
sb.AddSubsequence(SEQ_ID_ALIGN_SEQ_C1_FN_MV, alignSeqBuilder_C1_FN_MV);
|
|
|
|
// AlignSeq_C2_F2
|
|
sb.AddAction(SEQ_ID_SET_ALIGN_SEQ_PARAMS_C2_F2, SetAlignSeqParams);
|
|
sb.AddSubsequence(SEQ_ID_ALIGN_SEQ_C2_F2, alignSeqBuilder_C2_F2);
|
|
|
|
// AlignSeq_C2_F4_MV
|
|
sb.AddAction(SEQ_ID_SET_ALIGN_SEQ_PARAMS_C2_F4_MV, SetAlignSeqParams);
|
|
sb.AddSubsequence(SEQ_ID_ALIGN_SEQ_C2_F4_MV, alignSeqBuilder_C2_F4_MV);
|
|
|
|
// AlignSeq_C4_F4
|
|
sb.AddAction(SEQ_ID_SET_ALIGN_SEQ_PARAMS_C4_F4, SetAlignSeqParams);
|
|
sb.AddSubsequence(SEQ_ID_ALIGN_SEQ_C4_F4, alignSeqBuilder_C4_F4);
|
|
|
|
sb.AddAction(SEQ_ID_SEQ_COMPLETE, SeqComplete);
|
|
}
|
|
|
|
public override SequenceBuilder Builder(string seqName) {
|
|
SequenceBuilder sb = new SequenceBuilder(1000);
|
|
SetActions(sb);
|
|
sb.OnStopped(OnStopped);
|
|
sb.OnForceError(OnForceError);
|
|
|
|
sb.Flows(
|
|
sb.Init
|
|
> sb[SEQ_ID_INIT]
|
|
> sb[SEQ_ID_SELECT_ALIGN_SEQ]
|
|
> sb[SEQ_ID_SELECT_NG]
|
|
> sb.ForceError
|
|
);
|
|
sb.Flows(
|
|
// AlignSeq_C1_F1_M2C
|
|
sb[SEQ_ID_SELECT_ALIGN_SEQ]
|
|
> sb[SEQ_ID_SET_ALIGN_SEQ_P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LETE]
|
|
> sb.Final
|
|
);
|
|
|
|
#if SEQ_DRAW
|
|
sb.Draw($"{GetType().Name}.pdf");
|
|
#endif
|
|
|
|
return sb;
|
|
}
|
|
|
|
private SequenceActionResult Init(
|
|
SequenceContext context,
|
|
string id,
|
|
SequenceActionResult param) {
|
|
|
|
if (param.Param != null) {
|
|
_Params = param.Param as AlignSubSeqParams;
|
|
}
|
|
else {
|
|
LOG.E($"Param is null.");
|
|
return null;
|
|
}
|
|
|
|
_AlignRecipe = VisionRecipeManager.GetAlignRecipe(_Params.AlignInfo);
|
|
|
|
return SequenceAction.Ok();
|
|
}
|
|
|
|
private string SelectAlignSeq(
|
|
SequenceContext context,
|
|
string id,
|
|
ICollection<string> branches,
|
|
SequenceActionResult param) {
|
|
|
|
switch (_AlignRecipe.ProcParams.ProcFovType) {
|
|
case eProcFovType.C1_F1_M2C:
|
|
return SEQ_ID_SET_ALIGN_SEQ_PARAMS_C1_F1_M2C;
|
|
case eProcFovType.C1_F1_M2R:
|
|
return SEQ_ID_SET_ALIGN_SEQ_PARAMS_C1_F1_M2R;
|
|
case eProcFovType.C1_F2_MV:
|
|
case eProcFovType.C1_F4_MV:
|
|
return SEQ_ID_SET_ALIGN_SEQ_PARAMS_C1_FN_MV;
|
|
case eProcFovType.C2_F2:
|
|
return SEQ_ID_SET_ALIGN_SEQ_PARAMS_C2_F2;
|
|
case eProcFovType.C2_F4_MV:
|
|
return SEQ_ID_SET_ALIGN_SEQ_PARAMS_C2_F4_MV;
|
|
case eProcFovType.C4_F4:
|
|
return SEQ_ID_SET_ALIGN_SEQ_PARAMS_C4_F4;
|
|
}
|
|
return SEQ_ID_SELECT_NG;
|
|
}
|
|
|
|
private SequenceActionResult SelectNG(
|
|
SequenceContext context,
|
|
string id,
|
|
SequenceActionResult param) {
|
|
|
|
LOG.FuncE("There is no align sequence to choose from recipe.");
|
|
|
|
return SequenceAction.Error(E1.GENERIC);
|
|
}
|
|
|
|
private SequenceActionResult SetAlignSeqParams(
|
|
SequenceContext context,
|
|
string id,
|
|
SequenceActionResult param) {
|
|
|
|
switch (_AlignRecipe.ProcParams.ProcFovType) {
|
|
case eProcFovType.C1_F1_M2C:
|
|
return SequenceAction.Ok(
|
|
new AlignSeqParams_C1_F1_M2C(_Params.AlignInfo, _Params.DisplayType, _Params.SeqMode));
|
|
case eProcFovType.C1_F1_M2R:
|
|
return SequenceAction.Ok(
|
|
new AlignSeqParams_C1_F1_M2R(_Params.AlignInfo, _Params.DisplayType, _Params.SeqMode));
|
|
case eProcFovType.C1_F2_MV:
|
|
case eProcFovType.C1_F4_MV:
|
|
return SequenceAction.Ok(
|
|
new AlignSeqParams_C1_FN_MV(_Params.AlignInfo, _Params.FovPositions, _Params.DisplayType, _Params.SeqMode));
|
|
case eProcFovType.C2_F2:
|
|
return SequenceAction.Ok(
|
|
new AlignSeqParams_C2_F2(_Params.AlignInfo, _Params.FovPositions, _Params.DisplayType, _Params.SeqMode));
|
|
case eProcFovType.C2_F4_MV:
|
|
return SequenceAction.Ok(
|
|
new AlignSeqParams_C2_F4_MV(_Params.AlignInfo, _Params.FovPositions, _Params.DisplayType, _Params.SeqMode));
|
|
case eProcFovType.C4_F4:
|
|
return SequenceAction.Ok(
|
|
new AlignSeqParams_C4_F4(_Params.AlignInfo, _Params.FovPositions, _Params.DisplayType, _Params.SeqMode));
|
|
}
|
|
|
|
LOG.W("ProcFovType Not Matched.");
|
|
|
|
return SequenceAction.Error(E1.GENERIC);
|
|
}
|
|
|
|
private SequenceActionResult SeqComplete(
|
|
SequenceContext context,
|
|
string id,
|
|
SequenceActionResult param) { // Param : AlignResult
|
|
|
|
return SequenceAction.Ok(param.Param as AlignResult);
|
|
}
|
|
|
|
void OnStopped(
|
|
SequenceContext context) {
|
|
LOG.I($"{context.SequenceId} - STOP Handler");
|
|
HandleAbnormalFinish(context);
|
|
}
|
|
|
|
void OnForceError(
|
|
SequenceContext context, string id) {
|
|
LOG.E($"{context.SequenceId} - FORCE ERROR Handler");
|
|
HandleAbnormalFinish(context);
|
|
}
|
|
|
|
void HandleAbnormalFinish(
|
|
SequenceContext context) {
|
|
}
|
|
}
|
|
}
|