fix: ScoutNormal 페이지별 필드 로드 정정 (PageIndex 주입)

증상: 운전화면 페이지 이동 후에도 SeqScoutNormal이 이전 페이지(보통 0)의
스카우트 필드로 동작.
원인: LoadScoutField()가 GUI 캐시 selectedIndexNo 의존 — WinForms 티칭
콤보에서만 갱신되어 운전화면/자동운전 경로에선 stale.

- SeqScoutNormal_InitParam에 PageIndex 추가, 실행 시점 라이브 페이지
  (GetCurrentPageIndex)를 호출부(Recipe/Test VM)에서 명시 주입
- MainPage: LoadScoutField(int) 오버로드 + GetCurrentPageIndex() 추가
- 폴백: 페이지 없으면 selectedIndexNo 로드, 그래도 null이면 빈 리스트(NRE 방지)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
to3796zw 2026-06-19 17:44:35 +09:00
parent de7450474a
commit 4a655ecefb
4 changed files with 33 additions and 1 deletions

View File

@ -498,9 +498,27 @@ namespace GUI
} }
public List<ChildBufRowCol> LoadScoutField() public List<ChildBufRowCol> LoadScoutField()
{ {
// [기존 보존 2026-06-19] selectedIndexNo(GUI 캐시) 기반. 하위 호환용으로 남겨둠.
return DB.RecipeFieldScan.Instance.GetPageFieldScan( return DB.RecipeFieldScan.Instance.GetPageFieldScan(
DB.RecipeFieldScan.Instance.GetAutoPageName(selectedIndexNo)); DB.RecipeFieldScan.Instance.GetAutoPageName(selectedIndexNo));
} }
// [추가 2026-06-19] 페이지 인덱스를 명시 지정해 스카우트 필드 로드 (시퀀스 PageIndex 주입용)
public List<ChildBufRowCol> LoadScoutField(int pageIndex)
{
return DB.RecipeFieldScan.Instance.GetPageFieldScan(
DB.RecipeFieldScan.Instance.GetAutoPageName(pageIndex));
}
// [추가 2026-06-19] 현재 화면에 표시 중인 페이지 인덱스(라이브). 콤보박스 우선, 없으면 ActiveLayer.No.
// 로드 키를 stale 캐시(selectedIndexNo) 대신 라이브 값으로 얻기 위함.
public int GetCurrentPageIndex()
{
int idx = toolStripComboBoxPage.SelectedIndex;
if (idx < 0) {
var active = ScannerCanvasCtrlTeaching?.Model?.ActiveLayer;
idx = active != null ? active.No : 0;
}
return idx;
}
void SaveAndLoadFieldScanFromLasaDb(string inputStr = null) void SaveAndLoadFieldScanFromLasaDb(string inputStr = null)
{ {
string fullpath = inputStr == null ? DB.Dao.SystemRecipe.WorkRecipeFile : inputStr; string fullpath = inputStr == null ? DB.Dao.SystemRecipe.WorkRecipeFile : inputStr;

View File

@ -148,7 +148,13 @@ namespace WeldingCommon.Sequences
//CamConfig의 PosIndex 순서로 ScoutNoList를 파싱해서 사용하도록 함 //CamConfig의 PosIndex 순서로 ScoutNoList를 파싱해서 사용하도록 함
//_ChildBufRowCols = _CamConfig.ChildImage.ChildBufRowCols; //_ChildBufRowCols = _CamConfig.ChildImage.ChildBufRowCols;
var mainPage = CommonHelper.GetMainPage(); var mainPage = CommonHelper.GetMainPage();
_ChildBufRowCols = mainPage.LoadScoutField(); // [기존 2026-06-19 주석처리] GUI 전역 상태(selectedIndexNo)에 의존 → 페이지 정합성 버그
//_ChildBufRowCols = mainPage.LoadScoutField();
// [변경 2026-06-19] InitParam 으로 전달된 페이지 인덱스로 명시 로드
// 폴백: 해당 페이지가 없으면(인덱스 초과 등) selectedIndexNo 기반 로드, 그래도 null이면 빈 리스트로 NRE 방지.
_ChildBufRowCols = mainPage.LoadScoutField(_InitParam.PageIndex)
?? mainPage.LoadScoutField()
?? new List<ChildBufRowCol>();
_ScoutNoList = GenerateSortedScoutNoList(_ChildBufRowCols); _ScoutNoList = GenerateSortedScoutNoList(_ChildBufRowCols);
_ScoutNo = 0; _ScoutNo = 0;
@ -375,6 +381,10 @@ namespace WeldingCommon.Sequences
public bool IsRealTimeScout { get; set; } public bool IsRealTimeScout { get; set; }
public ScoutSeqParams ScoutSeqParams { get; set; } public ScoutSeqParams ScoutSeqParams { get; set; }
// [추가 2026-06-19] 스카우트 필드를 불러올 페이지 인덱스(0-base).
// 기존: SeqScoutNormal 이 MainPage.selectedIndexNo(GUI 전역 상태)에만 의존 → 페이지 이동/자동운전 시 stale.
// 변경: 호출부가 "현재 처리/표시 중인 페이지 번호"를 명시 주입.
public int PageIndex { get; set; } = 0;
} }
public class SeqScoutNormal_OutParam : OutParam public class SeqScoutNormal_OutParam : OutParam

View File

@ -251,6 +251,8 @@ namespace WeldingCommon.Views
var param = new SeqScoutNormal_InitParam() { var param = new SeqScoutNormal_InitParam() {
IsRealTimeScout = false, IsRealTimeScout = false,
ScoutSeqParams = scoutSeqParams, ScoutSeqParams = scoutSeqParams,
// [추가 2026-06-19] 현재 표시 중인 페이지의 스카우트 필드를 사용하도록 명시 주입
PageIndex = CommonHelper.GetMainPage().GetCurrentPageIndex(),
}; };
PopupSequenceDiagram(ref _WinSequenceDiagramScoutNormal, CommonSequenceIds.SeqScoutNormal, param); PopupSequenceDiagram(ref _WinSequenceDiagramScoutNormal, CommonSequenceIds.SeqScoutNormal, param);

View File

@ -361,6 +361,8 @@ namespace WeldingCommon.Views
var param = new SeqScoutNormal_InitParam() { var param = new SeqScoutNormal_InitParam() {
IsRealTimeScout = false, IsRealTimeScout = false,
ScoutSeqParams = new ScoutSeqParams(VisionRecipeManager.GetFovInfos()[0], eDisplayType.Machine_B), ScoutSeqParams = new ScoutSeqParams(VisionRecipeManager.GetFovInfos()[0], eDisplayType.Machine_B),
// [추가 2026-06-19] 현재 표시 중인 페이지 인덱스 주입
PageIndex = CommonHelper.GetMainPage().GetCurrentPageIndex(),
}; };
IsSequenceRunning_SeqScoutNormal = true; IsSequenceRunning_SeqScoutNormal = true;