Merge branch 'bugfix/processor-ui-fixes' of http://xr.flexing.ai:3000/UVCXR/OCTOPUS_TWIN-Demo
This commit is contained in:
@@ -231,34 +231,58 @@ private static EntityTabData? CreateNetworkTab(StageObjectManager.StageObject st
|
||||
CreateTwinAgentProgressItems(properties, propertyDict, ref orderIndex, stageObject);
|
||||
|
||||
// Processor 재사용 또는 생성 (Entity마다 독립적으로 유지)
|
||||
TwinAgentAutoProcessor processor = stageObject.GetProcessor<TwinAgentAutoProcessor>();
|
||||
if (processor == null)
|
||||
if (!stageObject.TryGetProcessor<TwinAgentAutoProcessor>(out var processor))
|
||||
{
|
||||
// 새로 생성
|
||||
processor = new TwinAgentAutoProcessor();
|
||||
processor.Initialize(stageObject, propertyDict);
|
||||
processor = new TwinAgentAutoProcessor(stageObject);
|
||||
stageObject.RegisterProcessor(processor);
|
||||
Debug.Log("[EntityPropertyAdapter] TwinAgentAutoProcessor 생성 및 등록");
|
||||
}
|
||||
|
||||
autoButton.ButtonText = "Run";
|
||||
// 이벤트 바인딩 (기존 구독 정리 후 최신 propertyDict로 재구독)
|
||||
processor.ClearBindings();
|
||||
processor.onMessage += (propertyId, value) =>
|
||||
{
|
||||
if (!propertyDict.TryGetValue(propertyId, out var item))
|
||||
return;
|
||||
|
||||
item.IsVisible = true;
|
||||
|
||||
// TextColor를 SetValue보다 먼저 설정해야 UI의 UpdateValue에서 올바른 색상을 읽음
|
||||
if (item is LabelProperty label)
|
||||
{
|
||||
label.TextColor = value switch
|
||||
{
|
||||
"Done" => Color.green,
|
||||
"Canceled" => new Color(1f, 0.647f, 0f),
|
||||
_ => Color.white
|
||||
};
|
||||
}
|
||||
|
||||
item.SetValue(value);
|
||||
};
|
||||
processor.onReset += () =>
|
||||
{
|
||||
foreach (var kvp in propertyDict)
|
||||
{
|
||||
if (kvp.Value is LabelProperty labelProp)
|
||||
labelProp.TextColor = Color.white;
|
||||
kvp.Value.SetValue("-");
|
||||
kvp.Value.IsVisible = true;
|
||||
}
|
||||
};
|
||||
// 백그라운드 완료/취소 시 버튼 텍스트 갱신
|
||||
processor.onComplete += () => { autoButton.ButtonText = "Run"; };
|
||||
processor.onCancel += () => { autoButton.ButtonText = "Run"; };
|
||||
|
||||
// 저장된 상태 복원
|
||||
if (processor.HasSavedState)
|
||||
{
|
||||
processor.RestoreState();
|
||||
autoButton.ButtonText = processor.IsRunning ? "Cancel" : "Run";
|
||||
}
|
||||
else
|
||||
{
|
||||
// 재사용 - 저장된 상태를 새 PropertyItem들에 복원
|
||||
Debug.Log($"[EntityPropertyAdapter] 기존 TwinAgentAutoProcessor 재사용 (IsRunning: {processor.IsRunning}, IsCompleted: {processor.IsCompleted}, HasSavedState: {processor.HasSavedState})");
|
||||
|
||||
if (processor.HasSavedState)
|
||||
{
|
||||
// 진행 상태가 있으면 복원 (실행 중, 완료, 취소 모두 포함)
|
||||
processor.RestoreUIState(propertyDict);
|
||||
autoButton.ButtonText = processor.IsRunning ? "Cancel" : "Run";
|
||||
}
|
||||
else
|
||||
{
|
||||
// 진행 상태가 없으면 PropertyItems만 업데이트
|
||||
processor.Initialize(stageObject, propertyDict);
|
||||
autoButton.ButtonText = "Run";
|
||||
}
|
||||
autoButton.ButtonText = "Run";
|
||||
}
|
||||
|
||||
// Auto 버튼 클릭 시 Run/Cancel 토글
|
||||
@@ -273,7 +297,8 @@ private static EntityTabData? CreateNetworkTab(StageObjectManager.StageObject st
|
||||
return;
|
||||
}
|
||||
|
||||
// Execute 실행
|
||||
// 이전 상태 초기화 후 실행 (Cancel 후 재실행 시 잔여 진행 내역 제거)
|
||||
processor.Reset();
|
||||
autoButton.ButtonText = "Cancel";
|
||||
await processor.Execute();
|
||||
autoButton.ButtonText = "Run";
|
||||
@@ -344,30 +369,27 @@ private static EntityTabData? CreateNetworkTab(StageObjectManager.StageObject st
|
||||
// Twin Agent 진행 상태 항목들
|
||||
if (isTwinAgent)
|
||||
{
|
||||
// Twin Agent로 전환 시: Processor의 저장된 상태 확인
|
||||
// 모든 항목 표시
|
||||
foreach (var kvp in propertyDict)
|
||||
{
|
||||
kvp.Value.IsVisible = true;
|
||||
}
|
||||
|
||||
// 저장된 상태가 있으면 복원 (실행 중, 완료, 취소 모두 포함)
|
||||
if (processor.HasSavedState)
|
||||
{
|
||||
// 진행 상태가 저장되어 있으면 복원 (실행 중, 완료, 취소 모두 포함)
|
||||
processor.RestoreUIState(propertyDict);
|
||||
processor.RestoreState();
|
||||
autoButton.ButtonText = processor.IsRunning ? "Cancel" : "Run";
|
||||
Debug.Log("[EntityPropertyAdapter] Twin Agent로 전환 → 저장된 UI 상태 복원");
|
||||
}
|
||||
else
|
||||
{
|
||||
// 진행 상태가 없으면 초기 상태 (첫 번째 항목만 visible)
|
||||
foreach (var kvp in propertyDict)
|
||||
{
|
||||
kvp.Value.IsVisible = false;
|
||||
}
|
||||
if (propertyDict.ContainsKey("get_entity_info_status"))
|
||||
{
|
||||
propertyDict["get_entity_info_status"].IsVisible = true;
|
||||
}
|
||||
Debug.Log("[EntityPropertyAdapter] Twin Agent로 전환 → 초기 상태");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Twin Agent가 아닌 경우: 모든 항목 숨김
|
||||
// Twin Agent가 아닌 경우: 진행 항목 숨김
|
||||
foreach (var kvp in propertyDict)
|
||||
{
|
||||
kvp.Value.IsVisible = false;
|
||||
@@ -412,14 +434,12 @@ private static void CreateTwinAgentProgressItems(
|
||||
propertyDict["get_entity_info_status"] = getEntityInfoStatus;
|
||||
|
||||
// 0-2. Extract Entity Network Info 상태
|
||||
var extractNetworkStatus = new LabelProperty("extract_network_info_status", "Extract Network Info", "-")
|
||||
{ IsVisible = false };
|
||||
var extractNetworkStatus = new LabelProperty("extract_network_info_status", "Extract Network Info", "-");
|
||||
readEntityGroup.AddItem(extractNetworkStatus);
|
||||
propertyDict["extract_network_info_status"] = extractNetworkStatus;
|
||||
|
||||
|
||||
// 0-3. Connecting Status
|
||||
var connectingStatus = new LabelProperty("connecting_status", "Connecting Status", "-")
|
||||
{ IsVisible = false };
|
||||
var connectingStatus = new LabelProperty("connecting_status", "Connecting Status", "-");
|
||||
readEntityGroup.AddItem(connectingStatus);
|
||||
propertyDict["connecting_status"] = connectingStatus;
|
||||
|
||||
@@ -429,32 +449,27 @@ private static void CreateTwinAgentProgressItems(
|
||||
var connectionGroup = new PropertyGroup("connection", "Connection", order: orderIndex++);
|
||||
|
||||
// 1-1. Server
|
||||
var serverStatus = new LabelProperty("server_status", "Server", "-")
|
||||
{ IsVisible = false };
|
||||
var serverStatus = new LabelProperty("server_status", "Server", "-");
|
||||
connectionGroup.AddItem(serverStatus);
|
||||
propertyDict["server_status"] = serverStatus;
|
||||
|
||||
|
||||
// 1-2. Port
|
||||
var portStatus = new LabelProperty("port_status", "Port", "-")
|
||||
{ IsVisible = false };
|
||||
var portStatus = new LabelProperty("port_status", "Port", "-");
|
||||
connectionGroup.AddItem(portStatus);
|
||||
propertyDict["port_status"] = portStatus;
|
||||
|
||||
|
||||
// 1-3. Protocol
|
||||
var protocolStatus = new LabelProperty("protocol_status", "Protocol", "-")
|
||||
{ IsVisible = false };
|
||||
var protocolStatus = new LabelProperty("protocol_status", "Protocol", "-");
|
||||
connectionGroup.AddItem(protocolStatus);
|
||||
propertyDict["protocol_status"] = protocolStatus;
|
||||
|
||||
|
||||
// 1-4. Status
|
||||
var serverStatusCheck = new LabelProperty("server_status_check", "Status", "-")
|
||||
{ IsVisible = false };
|
||||
var serverStatusCheck = new LabelProperty("server_status_check", "Status", "-");
|
||||
connectionGroup.AddItem(serverStatusCheck);
|
||||
propertyDict["server_status_check"] = serverStatusCheck;
|
||||
|
||||
|
||||
// 1-5. Speed
|
||||
var speedStatus = new LabelProperty("speed_status", "Speed", "-")
|
||||
{ IsVisible = false };
|
||||
var speedStatus = new LabelProperty("speed_status", "Speed", "-");
|
||||
connectionGroup.AddItem(speedStatus);
|
||||
propertyDict["speed_status"] = speedStatus;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user