Files
2025-12-08 21:06:05 +09:00

164 lines
5.1 KiB
C#

#nullable enable
using System;
using UnityEngine;
using UVC.Data.Core;
using UVC.Util;
namespace UVC.Factory.Component
{
[Flags]
public enum AreaType
{
None = 0,
//G층
RKG = 1 << 0,
Module = 1 << 1,
RankNorth = 1 << 2,
RankSouth = 1 << 3,
//1층
Examine = 1 << 4,
OverBridge = 1 << 5,
Cleaning = 1 << 6,
IROCVNorth = 1 << 7,
IROCVSouth = 1 << 8,
//각각 동일한이름
Front = 1 << 9,
Back = 1 << 10,
//Line
Buffer = 1 << 11,
Charging0 = 1 << 12,
Charging1 = 1 << 13,
NormalTempAG0 = 1 << 14,
NormalTempAG1 = 1 << 15,
NormalTempAG2 = 1 << 16,
NormalTempAG3 = 1 << 17,
HVC0 = 1 << 18,
HVC1 = 1 << 19,
HotTemp = 1 << 20,
CoolTemp = 1 << 21,
GFloor = 1 << 22,
FirstFloor = 1 << 23,
Line910 = 1 << 24,
Line1112 = 1 << 25
}
public enum PortStatus
{
OCCUPIED,
RESERVED,
DOWN,
EMPTY,
OCCUPIED_RESERVED,
BANNED,
}
public class Port : FactoryObject
{
[SerializeField]
public AreaType areaType;
[SerializeField]
public LayerMask baseLayerMask;
private SpriteRenderer statusBox;
protected override void Awake()
{
base.Awake();
statusBox = GetComponentInChildren<SpriteRenderer>();
if (statusBox == null)
{
Debug.LogWarning("StatusBox not found in Port object: " + gameObject.name);
}
PortManager.Instance.AddPort(name, this);
}
protected override void ProcessData(DataObject newData)
{
//{
// "EQP_ID": "HFB09ICS0100",
// "PORT_ID": "HFB09ICS0100_UOP01",
// "TOOLSTATUS": "RESERVED",
// "PORT_ACCESS_MODE": "AUTO",
// "UP_DOWN_STS": "U",
// "PORT_IDLE_TIME": "2025-03-25T11:52:23Z",
// "PORTCARRID": null,
// "LAST_PORT_EVENT_NAME": "UDCM",
// "PORTTYPE": "OUT",
// "PORTMODE": "UNLOAD",
// "AUTODISPATCHFLAG": "Y",
// "TIMESTAMP": "2025-03-25T11:52:23Z",
// "PORT_LOAD_TIME": "2025-03-25T11:50:17Z",
// "PORTNAME": "H09L_특성검사_ECS_E01_출고대1",
// "RESERVED_JOB_ID": "2F11462_849_6985366448988771",
// "RESERVED_CARRIER_ID": "2F11462",
// "JOB_ID": null,
// "FROM": "HFB09ICS0100,HFB09ICS0100_UOP01,NULL",
// "TO": "HFF09AGM0100,HFF09AGM0100_LBP19,NULL",
// "REQ_TIME": "2025-03-24T14:55:42Z",
// "TRANSPORT_JOB_TIMESTAMP": "2025-03-24T14:59:23Z"
//}
// 처음 데이터를 받는 경우 (data가 null일 때)
if (data == null)
{
// 받은 데이터를 내부 데이터 저장소에 저장합니다.
data = newData;
}
else // 이미 데이터가 있는 경우 (업데이트)
{
string? currentToolStatus = data.GetString("TOOLSTATUS");
if (!Enum.TryParse<PortStatus>(currentToolStatus, out PortStatus result))
{
Debug.Log($"wrong status {currentToolStatus}");
statusBox.color = Color.gray;
}
else
{
string? portAccessMode = data.GetString("PORT_ACCESS_MODE");
switch (result)
{
case PortStatus.RESERVED:
statusBox.color = ColorUtil.FromHex("#FFE02D");
break;
case PortStatus.OCCUPIED:
break;
case PortStatus.OCCUPIED_RESERVED:
statusBox.color = ColorUtil.FromHex("#3685FF");
break;
case PortStatus.BANNED:
statusBox.color = Color.black;
break;
case PortStatus.DOWN:
if (portAccessMode == "AUTO")
{
statusBox.color = ColorUtil.FromHex("#9F342D");
}
else
{
statusBox.color = Color.white;
}
break;
case PortStatus.EMPTY:
statusBox.color = Color.white;
break;
}
}
// 기존 데이터(data)에 새로운 데이터(newData)의 내용을 덮어씁니다.
foreach (var keyValue in newData)
{
data[keyValue.Key] = keyValue.Value;
}
}
}
}
}