1
This commit is contained in:
@@ -231,34 +231,58 @@ private static EntityTabData? CreateNetworkTab(StageObjectManager.StageObject st
|
|||||||
CreateTwinAgentProgressItems(properties, propertyDict, ref orderIndex, stageObject);
|
CreateTwinAgentProgressItems(properties, propertyDict, ref orderIndex, stageObject);
|
||||||
|
|
||||||
// Processor 재사용 또는 생성 (Entity마다 독립적으로 유지)
|
// Processor 재사용 또는 생성 (Entity마다 독립적으로 유지)
|
||||||
TwinAgentAutoProcessor processor = stageObject.GetProcessor<TwinAgentAutoProcessor>();
|
if (!stageObject.TryGetProcessor<TwinAgentAutoProcessor>(out var processor))
|
||||||
if (processor == null)
|
|
||||||
{
|
{
|
||||||
// 새로 생성
|
processor = new TwinAgentAutoProcessor(stageObject);
|
||||||
processor = new TwinAgentAutoProcessor();
|
|
||||||
processor.Initialize(stageObject, propertyDict);
|
|
||||||
stageObject.RegisterProcessor(processor);
|
stageObject.RegisterProcessor(processor);
|
||||||
Debug.Log("[EntityPropertyAdapter] TwinAgentAutoProcessor 생성 및 등록");
|
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
|
else
|
||||||
{
|
{
|
||||||
// 재사용 - 저장된 상태를 새 PropertyItem들에 복원
|
autoButton.ButtonText = "Run";
|
||||||
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";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Auto 버튼 클릭 시 Run/Cancel 토글
|
// Auto 버튼 클릭 시 Run/Cancel 토글
|
||||||
@@ -273,7 +297,8 @@ private static EntityTabData? CreateNetworkTab(StageObjectManager.StageObject st
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute 실행
|
// 이전 상태 초기화 후 실행 (Cancel 후 재실행 시 잔여 진행 내역 제거)
|
||||||
|
processor.Reset();
|
||||||
autoButton.ButtonText = "Cancel";
|
autoButton.ButtonText = "Cancel";
|
||||||
await processor.Execute();
|
await processor.Execute();
|
||||||
autoButton.ButtonText = "Run";
|
autoButton.ButtonText = "Run";
|
||||||
@@ -344,30 +369,27 @@ private static EntityTabData? CreateNetworkTab(StageObjectManager.StageObject st
|
|||||||
// Twin Agent 진행 상태 항목들
|
// Twin Agent 진행 상태 항목들
|
||||||
if (isTwinAgent)
|
if (isTwinAgent)
|
||||||
{
|
{
|
||||||
// Twin Agent로 전환 시: Processor의 저장된 상태 확인
|
// 모든 항목 표시
|
||||||
|
foreach (var kvp in propertyDict)
|
||||||
|
{
|
||||||
|
kvp.Value.IsVisible = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 저장된 상태가 있으면 복원 (실행 중, 완료, 취소 모두 포함)
|
||||||
if (processor.HasSavedState)
|
if (processor.HasSavedState)
|
||||||
{
|
{
|
||||||
// 진행 상태가 저장되어 있으면 복원 (실행 중, 완료, 취소 모두 포함)
|
processor.RestoreState();
|
||||||
processor.RestoreUIState(propertyDict);
|
autoButton.ButtonText = processor.IsRunning ? "Cancel" : "Run";
|
||||||
Debug.Log("[EntityPropertyAdapter] Twin Agent로 전환 → 저장된 UI 상태 복원");
|
Debug.Log("[EntityPropertyAdapter] Twin Agent로 전환 → 저장된 UI 상태 복원");
|
||||||
}
|
}
|
||||||
else
|
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로 전환 → 초기 상태");
|
Debug.Log("[EntityPropertyAdapter] Twin Agent로 전환 → 초기 상태");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Twin Agent가 아닌 경우: 모든 항목 숨김
|
// Twin Agent가 아닌 경우: 진행 항목 숨김
|
||||||
foreach (var kvp in propertyDict)
|
foreach (var kvp in propertyDict)
|
||||||
{
|
{
|
||||||
kvp.Value.IsVisible = false;
|
kvp.Value.IsVisible = false;
|
||||||
@@ -412,14 +434,12 @@ private static void CreateTwinAgentProgressItems(
|
|||||||
propertyDict["get_entity_info_status"] = getEntityInfoStatus;
|
propertyDict["get_entity_info_status"] = getEntityInfoStatus;
|
||||||
|
|
||||||
// 0-2. Extract Entity Network Info 상태
|
// 0-2. Extract Entity Network Info 상태
|
||||||
var extractNetworkStatus = new LabelProperty("extract_network_info_status", "Extract Network Info", "-")
|
var extractNetworkStatus = new LabelProperty("extract_network_info_status", "Extract Network Info", "-");
|
||||||
{ IsVisible = false };
|
|
||||||
readEntityGroup.AddItem(extractNetworkStatus);
|
readEntityGroup.AddItem(extractNetworkStatus);
|
||||||
propertyDict["extract_network_info_status"] = extractNetworkStatus;
|
propertyDict["extract_network_info_status"] = extractNetworkStatus;
|
||||||
|
|
||||||
// 0-3. Connecting Status
|
// 0-3. Connecting Status
|
||||||
var connectingStatus = new LabelProperty("connecting_status", "Connecting Status", "-")
|
var connectingStatus = new LabelProperty("connecting_status", "Connecting Status", "-");
|
||||||
{ IsVisible = false };
|
|
||||||
readEntityGroup.AddItem(connectingStatus);
|
readEntityGroup.AddItem(connectingStatus);
|
||||||
propertyDict["connecting_status"] = connectingStatus;
|
propertyDict["connecting_status"] = connectingStatus;
|
||||||
|
|
||||||
@@ -429,32 +449,27 @@ private static void CreateTwinAgentProgressItems(
|
|||||||
var connectionGroup = new PropertyGroup("connection", "Connection", order: orderIndex++);
|
var connectionGroup = new PropertyGroup("connection", "Connection", order: orderIndex++);
|
||||||
|
|
||||||
// 1-1. Server
|
// 1-1. Server
|
||||||
var serverStatus = new LabelProperty("server_status", "Server", "-")
|
var serverStatus = new LabelProperty("server_status", "Server", "-");
|
||||||
{ IsVisible = false };
|
|
||||||
connectionGroup.AddItem(serverStatus);
|
connectionGroup.AddItem(serverStatus);
|
||||||
propertyDict["server_status"] = serverStatus;
|
propertyDict["server_status"] = serverStatus;
|
||||||
|
|
||||||
// 1-2. Port
|
// 1-2. Port
|
||||||
var portStatus = new LabelProperty("port_status", "Port", "-")
|
var portStatus = new LabelProperty("port_status", "Port", "-");
|
||||||
{ IsVisible = false };
|
|
||||||
connectionGroup.AddItem(portStatus);
|
connectionGroup.AddItem(portStatus);
|
||||||
propertyDict["port_status"] = portStatus;
|
propertyDict["port_status"] = portStatus;
|
||||||
|
|
||||||
// 1-3. Protocol
|
// 1-3. Protocol
|
||||||
var protocolStatus = new LabelProperty("protocol_status", "Protocol", "-")
|
var protocolStatus = new LabelProperty("protocol_status", "Protocol", "-");
|
||||||
{ IsVisible = false };
|
|
||||||
connectionGroup.AddItem(protocolStatus);
|
connectionGroup.AddItem(protocolStatus);
|
||||||
propertyDict["protocol_status"] = protocolStatus;
|
propertyDict["protocol_status"] = protocolStatus;
|
||||||
|
|
||||||
// 1-4. Status
|
// 1-4. Status
|
||||||
var serverStatusCheck = new LabelProperty("server_status_check", "Status", "-")
|
var serverStatusCheck = new LabelProperty("server_status_check", "Status", "-");
|
||||||
{ IsVisible = false };
|
|
||||||
connectionGroup.AddItem(serverStatusCheck);
|
connectionGroup.AddItem(serverStatusCheck);
|
||||||
propertyDict["server_status_check"] = serverStatusCheck;
|
propertyDict["server_status_check"] = serverStatusCheck;
|
||||||
|
|
||||||
// 1-5. Speed
|
// 1-5. Speed
|
||||||
var speedStatus = new LabelProperty("speed_status", "Speed", "-")
|
var speedStatus = new LabelProperty("speed_status", "Speed", "-");
|
||||||
{ IsVisible = false };
|
|
||||||
connectionGroup.AddItem(speedStatus);
|
connectionGroup.AddItem(speedStatus);
|
||||||
propertyDict["speed_status"] = speedStatus;
|
propertyDict["speed_status"] = speedStatus;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user