데이터 즉시 업데이트 flag 추가
This commit is contained in:
@@ -1,12 +1,10 @@
|
||||
#nullable enable
|
||||
using EPOOutline;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UVC.Data;
|
||||
using UVC.Data.Core;
|
||||
using UVC.Extention;
|
||||
using UVC.Factory.Playback;
|
||||
|
||||
namespace UVC.Factory.Component
|
||||
@@ -65,12 +63,6 @@ namespace UVC.Factory.Component
|
||||
private float agvFloorOffset = 200f; //agv의 층을 구별하기 위한 값
|
||||
private float agvZOffset = -197.5f; //층을 옮긴 agv의 위치를 잡아주기 위한 값
|
||||
|
||||
// true일 경우, UpdatePositionAndRotation에서 즉시 위치와 회전을 변경합니다.
|
||||
// 한번으로 않되서 3번 즉시 변경하도록 설정
|
||||
private bool needUpdateImmediately = false;
|
||||
private int maxImmediateUpdateCount = 3;
|
||||
private int immediateUpdateCount = 0;
|
||||
|
||||
/// <summary>
|
||||
/// AGV 객체가 생성될 때 처음 한 번 호출되는 초기화 메서드입니다.
|
||||
/// </summary>
|
||||
@@ -93,12 +85,12 @@ namespace UVC.Factory.Component
|
||||
public override void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
// 사용자가 AGV를 클릭했을 때 정보창에 표시될 데이터 항목과 순서를 정의합니다.
|
||||
if(dataDisplaySetting == null) dataDisplaySetting = UserSetting.Get("AGV");
|
||||
if (dataDisplaySetting == null) dataDisplaySetting = UserSetting.Get("AGV");
|
||||
base.OnPointerClick(eventData);
|
||||
}
|
||||
|
||||
private void OnChangeTimeScaleHandler(float timeScale)
|
||||
{
|
||||
{
|
||||
this.timeScale = timeScale;
|
||||
}
|
||||
|
||||
@@ -108,7 +100,7 @@ namespace UVC.Factory.Component
|
||||
base.OnDestroy();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 선택 된 효과로 외곽선을 표시합니다.
|
||||
@@ -126,17 +118,6 @@ namespace UVC.Factory.Component
|
||||
if (outlinable != null) outlinable.enabled = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 즉시 객체의 상태를 업데이트합니다.
|
||||
/// </summary>
|
||||
/// <param name="count">업데이트 횟수. 기본값은 1입니다.</param>
|
||||
public override void UpdateImmediately(int count = 3)
|
||||
{
|
||||
needUpdateImmediately = true; // 다음 데이터 업데이트에서 즉시 위치와 회전을 변경하도록 플래그를 설정합니다.
|
||||
immediateUpdateCount = 0;
|
||||
maxImmediateUpdateCount = count;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// AGVManager로부터 새로운 데이터를 받았을 때 호출되는 핵심 메서드입니다.
|
||||
@@ -149,25 +130,22 @@ namespace UVC.Factory.Component
|
||||
/// <param name="newData">AGV의 최신 정보가 담긴 데이터 객체입니다.</param>
|
||||
protected override void ProcessData(DataObject newData)
|
||||
{
|
||||
// 새 데이터로 위치와 회전을 즉시 설정합니다.
|
||||
UpdatePositionAndRotation(newData);
|
||||
if (newData.IsUpdateImmediately)
|
||||
{
|
||||
transform.position = targetPosition;
|
||||
transform.rotation = targetRotation;
|
||||
}
|
||||
|
||||
// 처음 데이터를 받는 경우 (data가 null일 때)
|
||||
if (data == null)
|
||||
{
|
||||
// 새 데이터로 위치와 회전을 즉시 설정합니다.
|
||||
UpdatePositionAndRotation(newData);
|
||||
// 받은 데이터를 내부 데이터 저장소에 저장합니다.
|
||||
data = newData;
|
||||
}
|
||||
else // 이미 데이터가 있는 경우 (업데이트)
|
||||
{
|
||||
// 새 데이터를 기반으로 목표 위치와 회전을 갱신합니다.
|
||||
UpdatePositionAndRotation(newData);
|
||||
if (needUpdateImmediately)
|
||||
{
|
||||
transform.position = targetPosition;
|
||||
transform.rotation = targetRotation;
|
||||
immediateUpdateCount++;
|
||||
if (immediateUpdateCount >= maxImmediateUpdateCount) needUpdateImmediately = false;
|
||||
}
|
||||
// 기존 데이터(data)에 새로운 데이터(newData)의 내용을 덮어씁니다.
|
||||
foreach (var keyValue in newData)
|
||||
{
|
||||
@@ -232,7 +210,7 @@ namespace UVC.Factory.Component
|
||||
{
|
||||
float x = currentX.Value;
|
||||
float y = currentY.Value;
|
||||
|
||||
|
||||
if ((newX.HasValue && x != newX) || (newY.HasValue && y != newY))
|
||||
{
|
||||
Vector3 newTargetPosition = transform.position;
|
||||
@@ -307,10 +285,10 @@ namespace UVC.Factory.Component
|
||||
|
||||
private void UpdateStats()
|
||||
{
|
||||
if(data == null) return;
|
||||
if (data == null) return;
|
||||
string? stats = data.GetString("VHL_STATE");
|
||||
if (stats == null) return;
|
||||
if(stats == "91" || stats == "92" || stats == "93" || stats == "94")//CHARGING
|
||||
if (stats == "91" || stats == "92" || stats == "93" || stats == "94")//CHARGING
|
||||
{
|
||||
ChangeColor(new Color(0.7f, 0.12f, 0.0f, 1.0f));//orange
|
||||
}
|
||||
@@ -321,7 +299,7 @@ namespace UVC.Factory.Component
|
||||
else
|
||||
{
|
||||
string? trayID = data.GetString("CARRIER_ID");
|
||||
if(string.IsNullOrEmpty(trayID))
|
||||
if (string.IsNullOrEmpty(trayID))
|
||||
{
|
||||
ChangeColor(Color.yellow); // 트레이 ID가 없으면 기본 색상으로 설정
|
||||
}
|
||||
@@ -334,9 +312,9 @@ namespace UVC.Factory.Component
|
||||
|
||||
private void ChangeColor(Color color)
|
||||
{
|
||||
if(color == Color.red && isRed && modelRenderer != null) return; // 이미 빨간색이면 변경하지 않음
|
||||
if (color == Color.red && isRed && modelRenderer != null) return; // 이미 빨간색이면 변경하지 않음
|
||||
isRed = color == Color.red;
|
||||
if(modelRenderer != null) modelRenderer!.material.color = color;
|
||||
if (modelRenderer != null) modelRenderer!.material.color = color;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -386,7 +364,6 @@ namespace UVC.Factory.Component
|
||||
public override void UnregisterFactoryObject()
|
||||
{
|
||||
base.UnregisterFactoryObject();
|
||||
needUpdateImmediately = false; // 파괴 시 즉시 위치와 회전 변경 플래그를 초기화합니다.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,17 +222,6 @@ namespace UVC.Factory.Component
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 즉시 객체의 상태를 업데이트합니다.
|
||||
/// </summary>
|
||||
public void UpdateImmediately(int count = 1)
|
||||
{
|
||||
if (pool == null) return;
|
||||
foreach (var agv in pool.ActiveItems.Values)
|
||||
{
|
||||
if (agv != null) agv.UpdateImmediately(count);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// AGVManager가 파괴될 때 호출됩니다.
|
||||
|
||||
@@ -145,7 +145,7 @@ namespace UVC.Factory.Playback
|
||||
httpRequestConfig.AddSplitConfig("ALARM", DataMapperValidator.Get("ALARM"));
|
||||
foreach (var item in list)
|
||||
{
|
||||
HttpDataProcessor.ProcessSplitResponse(httpRequestConfig, item.data);
|
||||
HttpDataProcessor.ProcessSplitResponse(httpRequestConfig, item.data, null, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user