asdf
This commit is contained in:
@@ -141,16 +141,18 @@ public class statisticsMove
|
||||
{
|
||||
public int total_moved;
|
||||
}
|
||||
|
||||
public enum UnLoadingState
|
||||
{
|
||||
store,
|
||||
queue,
|
||||
defectStore,
|
||||
defectQueue
|
||||
}
|
||||
#endregion
|
||||
|
||||
public class SimulationModelMove : SimulationModel
|
||||
{
|
||||
string eventLoading = "move_loading";
|
||||
string eventMove = "move_moving";
|
||||
string eventUnloading = "move_unloading";
|
||||
string eventSpeed = "move_speed_factor_applied";
|
||||
string eventReturning = "move_returning";
|
||||
|
||||
[Header("Transport")]
|
||||
public List<GameObject> listProducts = new List<GameObject>();
|
||||
public Transform productPos;
|
||||
@@ -234,142 +236,40 @@ public class SimulationModelMove : SimulationModel
|
||||
var wrapclass = JsonConvert.DeserializeObject<SimulationDefaultJson>(data);
|
||||
if (wrapclass == null || string.IsNullOrEmpty(wrapclass._event))
|
||||
return;
|
||||
/*
|
||||
string eventLoading = "move_loading";
|
||||
string eventMove = "move_moving";
|
||||
string eventUnloading = "move_unloading";
|
||||
string eventSpeed = "move_speed_factor_applied";
|
||||
string eventReturning = "move_returning";
|
||||
*/
|
||||
|
||||
switch (wrapclass._event)
|
||||
{
|
||||
case "move_loading":
|
||||
LoadingCargo(wrapclass.data.ToString());
|
||||
break;
|
||||
break;
|
||||
case "move_moving":
|
||||
Moving(wrapclass.data.ToString());
|
||||
break;
|
||||
case "move_unloading":
|
||||
break;
|
||||
case "move_speed_factor_applied":
|
||||
break;
|
||||
case "move_returning":
|
||||
break;
|
||||
}
|
||||
if (wrapclass._event.Contains(eventMove))
|
||||
{
|
||||
var moveData_Move = JsonConvert.DeserializeObject<MoveDataClass_Move_Moving>(wrapclass.data.ToString());
|
||||
elapsedTime = 0;
|
||||
arrivalTime = moveData_Move.time;
|
||||
originalPos = transform.position;
|
||||
prevPos = transform.position;
|
||||
|
||||
if (moveData_Move.input.queues != null && moveData_Move.input.queues.Count >= 1)
|
||||
{
|
||||
string queueID = moveData_Move.input.queues[0].ToString();
|
||||
SimulationModel model = DataManager.I.GetModel(queueID);
|
||||
SimulationModelStore storeModel = model.GetComponent<SimulationModelStore>();
|
||||
origin = storeModel.GetTransporterPosition();
|
||||
}
|
||||
else if (moveData_Move.input.stores != null && moveData_Move.input.stores.Count >= 1)
|
||||
{
|
||||
string storeID = moveData_Move.input.stores[0].ToString();
|
||||
SimulationModel model = DataManager.I.GetModel(storeID);
|
||||
SimulationModelStore storeModel = model.GetComponent<SimulationModelStore>();
|
||||
origin = storeModel.GetTransporterPosition();
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(moveData_Move.output.queue))
|
||||
{
|
||||
SimulationModel model = DataManager.I.GetModel(moveData_Move.output.queue);
|
||||
SimulationModelStore storeModel = model.GetComponent<SimulationModelStore>();
|
||||
destination = storeModel.GetTransporterPosition();
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(moveData_Move.output.store))
|
||||
{
|
||||
SimulationModel model = DataManager.I.GetModel(moveData_Move.output.store);
|
||||
SimulationModelStore storeModel = model.GetComponent<SimulationModelStore>();
|
||||
destination = storeModel.GetTransporterPosition();
|
||||
}
|
||||
}
|
||||
else if (wrapclass._event.Contains(eventUnloading))
|
||||
{
|
||||
string targetID = "";
|
||||
|
||||
if (wrapclass._event.Contains("defect_store"))
|
||||
{
|
||||
var moveData_unLoading = JsonConvert.DeserializeObject<MoveDataClass_Unloading_Defect_Store>(wrapclass.data.ToString());
|
||||
targetID = moveData_unLoading.store_name;
|
||||
}
|
||||
else if (wrapclass._event.Contains("defect"))
|
||||
{
|
||||
var moveData_unLoading = JsonConvert.DeserializeObject<MoveDataClass_Unloading_Defect>(wrapclass.data.ToString());
|
||||
targetID = moveData_unLoading.output_queue;
|
||||
}
|
||||
else if (wrapclass._event.Contains("unloading_store"))
|
||||
{
|
||||
//Debug.Log(wrapclass.data.ToString());
|
||||
var moveData_unLoading = JsonConvert.DeserializeObject<MoveDataClass_Unloading_Store>(wrapclass.data.ToString());
|
||||
targetID = moveData_unLoading.store_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
var moveData_unLoading = JsonConvert.DeserializeObject<MoveDataClass_Unloading>(wrapclass.data.ToString());
|
||||
targetID = moveData_unLoading.output_queue;
|
||||
}
|
||||
|
||||
var model = DataManager.I.GetModel(targetID);
|
||||
if(model == null)
|
||||
{
|
||||
Debug.LogWarning($"Datamanager Model Null!!!!! TargetID:{targetID}");
|
||||
return;
|
||||
}
|
||||
SimulationModelStore storeModel = model.GetComponent<SimulationModelStore>();
|
||||
|
||||
if (listProducts.Count > 0)
|
||||
{
|
||||
GameObject product = listProducts[0];
|
||||
//storeModel.StoreProduct(product);
|
||||
listProducts.Remove(product);
|
||||
Destroy(product);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("Trying to unload from empty transporter : " + nodeID);
|
||||
}
|
||||
}
|
||||
if (wrapclass._event.Contains("move_arrived"))
|
||||
{
|
||||
var moveData_arrived = JsonConvert.DeserializeObject<MoveDataClass_Arrived>(wrapclass.data.ToString());
|
||||
currentCount -= moveData_arrived.count;
|
||||
SetBubble(currentCount);
|
||||
}
|
||||
if (wrapclass._event.Contains(eventSpeed))
|
||||
{
|
||||
var moveData_Speed = JsonConvert.DeserializeObject<MoveDataClass_Speed_Factor_Applied>(wrapclass.data.ToString());
|
||||
float originalTime = moveData_Speed.original;
|
||||
float adjustedTime = moveData_Speed.adjusted;
|
||||
arrivalTime += adjustedTime - originalTime;
|
||||
elapsedTime = 0;
|
||||
originalPos = transform.position;
|
||||
prevPos = transform.position;
|
||||
}
|
||||
if (wrapclass._event.Contains(eventReturning))
|
||||
{
|
||||
var moveData_Return = JsonConvert.DeserializeObject<MoveDataClass_returning>(wrapclass.data.ToString());
|
||||
elapsedTime = 0;
|
||||
arrivalTime = moveData_Return.return_time;
|
||||
originalPos = transform.position;
|
||||
prevPos = transform.position;
|
||||
if (origin != null)
|
||||
{
|
||||
destination = origin;
|
||||
}
|
||||
}
|
||||
if (wrapclass._event.Contains("move_statistics_update"))
|
||||
{
|
||||
totalMoved = JsonConvert.DeserializeObject<MoveDataClassStatistics>(wrapclass.data.ToString()).statistics.total_moved;
|
||||
SetBubble(totalMoved);
|
||||
case "move_unloading":
|
||||
Unloading(wrapclass.data.ToString(), UnLoadingState.queue);
|
||||
break;
|
||||
case "move_unloading_store":
|
||||
Unloading(wrapclass.data.ToString(), UnLoadingState.store);
|
||||
break;
|
||||
case "move_unloading_defect":
|
||||
Unloading(wrapclass.data.ToString(), UnLoadingState.defectQueue);
|
||||
break;
|
||||
case "move_unloading_defect_store":
|
||||
Unloading(wrapclass.data.ToString(), UnLoadingState.defectStore);
|
||||
break;
|
||||
case "move_arrived":
|
||||
Arrive(wrapclass.data.ToString());
|
||||
break;
|
||||
case "move_speed_factor_applied":
|
||||
SpeedFactorApply(wrapclass.data.ToString());
|
||||
break;
|
||||
case "move_returning":
|
||||
Returning(wrapclass.data.ToString());
|
||||
break;
|
||||
case "move_statistics_update":
|
||||
totalMoved = JsonConvert.DeserializeObject<MoveDataClassStatistics>(wrapclass.data.ToString()).statistics.total_moved;
|
||||
SetBubble(totalMoved);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -411,7 +311,6 @@ public class SimulationModelMove : SimulationModel
|
||||
originalPos = transform.position;
|
||||
prevPos = transform.position;
|
||||
|
||||
// origin 설정 (입력 큐 / 스토어)
|
||||
string inputId = GetFirstNonEmpty(moveData.input?.queues, moveData.input?.stores);
|
||||
if (!string.IsNullOrEmpty(inputId))
|
||||
{
|
||||
@@ -420,7 +319,6 @@ public class SimulationModelMove : SimulationModel
|
||||
origin = model.GetTransporterPosition();
|
||||
}
|
||||
|
||||
// destination 설정 (출력 큐 / 스토어)
|
||||
if (!string.IsNullOrEmpty(moveData.output?.queue))
|
||||
{
|
||||
var model = DataManager.I.GetModel(moveData.output.queue) as SimulationModelStore;
|
||||
@@ -460,6 +358,92 @@ public class SimulationModelMove : SimulationModel
|
||||
}
|
||||
}
|
||||
|
||||
private void Unloading(string data, UnLoadingState state)
|
||||
{
|
||||
string targetID = string.Empty;
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case UnLoadingState.store:
|
||||
var store = JsonConvert.DeserializeObject<MoveDataClass_Unloading_Store>(data);
|
||||
targetID = store?.store_name ?? string.Empty;
|
||||
break;
|
||||
case UnLoadingState.queue:
|
||||
var queue = JsonConvert.DeserializeObject<MoveDataClass_Unloading>(data);
|
||||
targetID = queue?.output_queue ?? string.Empty;
|
||||
break;
|
||||
case UnLoadingState.defectStore:
|
||||
var defectStore = JsonConvert.DeserializeObject<MoveDataClass_Unloading_Defect_Store>(data);
|
||||
targetID = defectStore?.store_name ?? string.Empty;
|
||||
break;
|
||||
case UnLoadingState.defectQueue:
|
||||
var defectQueue = JsonConvert.DeserializeObject<MoveDataClass_Unloading_Defect>(data);
|
||||
targetID = defectQueue?.output_queue ?? string.Empty;
|
||||
break;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(targetID))
|
||||
return;
|
||||
|
||||
var model = DataManager.I.GetModel(targetID);
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var storeModel = model.GetComponent<SimulationModelStore>();
|
||||
|
||||
if (listProducts.Count > 0)
|
||||
{
|
||||
var product = listProducts[0];
|
||||
// storeModel?.StoreProduct(product); // 필요 시 활성화
|
||||
listProducts.RemoveAt(0);
|
||||
Destroy(product);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("Trying to unload from empty transporter : " + nodeID);
|
||||
}
|
||||
}
|
||||
|
||||
private void Arrive(string data)
|
||||
{
|
||||
var arrived = JsonConvert.DeserializeObject<MoveDataClass_Arrived>(data);
|
||||
if (arrived == null)
|
||||
return;
|
||||
|
||||
currentCount -= arrived.count;
|
||||
SetBubble(currentCount);
|
||||
}
|
||||
|
||||
private void SpeedFactorApply(string data)
|
||||
{
|
||||
var speedData = JsonConvert.DeserializeObject<MoveDataClass_Speed_Factor_Applied>(data);
|
||||
if (speedData == null)
|
||||
return;
|
||||
|
||||
float originalTime = speedData.original;
|
||||
float adjustedTime = speedData.adjusted;
|
||||
arrivalTime += adjustedTime - originalTime;
|
||||
elapsedTime = 0f;
|
||||
originalPos = transform.position;
|
||||
prevPos = transform.position;
|
||||
}
|
||||
|
||||
private void Returning(string data)
|
||||
{
|
||||
var ret = JsonConvert.DeserializeObject<MoveDataClass_returning>(data);
|
||||
if (ret == null)
|
||||
return;
|
||||
|
||||
elapsedTime = 0f;
|
||||
arrivalTime = ret.return_time;
|
||||
originalPos = transform.position;
|
||||
prevPos = transform.position;
|
||||
if (origin != null)
|
||||
destination = origin;
|
||||
}
|
||||
|
||||
public override void SetBubble(object data)
|
||||
{
|
||||
string msg = $"{currentCount}/{totalMoved}";
|
||||
|
||||
Reference in New Issue
Block a user