rightweighting
This commit is contained in:
@@ -206,197 +206,6 @@ public class SimulationModelMove : SimulationModel
|
||||
|
||||
bool isFirstTransport = true;
|
||||
|
||||
/*
|
||||
protected override IEnumerator RunSimulationCoroutine()
|
||||
{
|
||||
yield return new WaitUntil(() => !string.IsNullOrEmpty(nodeID));
|
||||
while (dataQueue == null)
|
||||
{
|
||||
dataQueue = MQTTDataBase.Instance.GetDataQueue(nodeID);
|
||||
if (dataQueue == null)
|
||||
yield return null;
|
||||
else
|
||||
break;
|
||||
}
|
||||
while (true)
|
||||
{
|
||||
if (dataQueue.IsEmpty)
|
||||
{
|
||||
yield return null;
|
||||
continue;
|
||||
}
|
||||
if (dataQueue.TryDequeue(out JObject currentData))
|
||||
{
|
||||
string eventKey = "_event";
|
||||
string[] arrivalTimeKey = { "data", "time" };
|
||||
string[] returnTimeKey = { "data", "return_time" };
|
||||
string[] originalTimeKey = { "data", "original" };
|
||||
string[] adjustedTimeKey = { "data", "adjusted" };
|
||||
string[] inputQueueKey = { "data", "input", "queues" };
|
||||
string[] inputStoreKey = { "data", "input", "stores" };
|
||||
string[] outputQueueKey = { "data", "output", "queue" };
|
||||
string[] outputStoreKey = { "data", "output", "store" };
|
||||
string[] sourceQueueKey = { "data", "source_queues" };
|
||||
string[] sourceStoreKey = { "data", "source_stores" };
|
||||
string[] loadCountKey = { "data", "loaded_count" };
|
||||
string[] unloadQueueKey = { "data", "queue_name" };
|
||||
string[] unloadStoreKey = { "data", "store_name" };
|
||||
|
||||
if (currentData.ContainsKey(eventKey))
|
||||
{
|
||||
string value = currentData[eventKey].ToString();
|
||||
|
||||
|
||||
if (value.Contains(eventLoading))
|
||||
{
|
||||
yield return null;
|
||||
|
||||
JArray sourceQueues = GetJsonArray(currentData, sourceQueueKey);
|
||||
JArray sourceStores = GetJsonArray(currentData, sourceStoreKey);
|
||||
int loadCount = GetJsonIntValue(currentData, loadCountKey);
|
||||
if (sourceQueues != null && sourceQueues.HasValues)
|
||||
{
|
||||
string queueID = sourceQueues[0].ToString();
|
||||
SimulationModel model = DataManager.I.GetModel(queueID);
|
||||
SimulationModelStore storeModel = (SimulationModelStore)model;
|
||||
for (int i = 0; i < loadCount; i++)
|
||||
{
|
||||
GameObject product = null;
|
||||
yield return new WaitUntil(() =>
|
||||
{
|
||||
product = storeModel.GetProduct();
|
||||
return product != null;
|
||||
});
|
||||
product.transform.parent = productPos;
|
||||
product.transform.localPosition = Vector3.zero;
|
||||
product.transform.localRotation = Quaternion.identity;
|
||||
listProducts.Add(product);
|
||||
}
|
||||
}
|
||||
else if (sourceStores != null && sourceStores.HasValues)
|
||||
{
|
||||
string storeID = sourceStores[0].ToString();
|
||||
SimulationModel model = DataManager.I.GetModel(storeID);
|
||||
SimulationModelStore storeModel = (SimulationModelStore)model;
|
||||
for (int i = 0; i < loadCount; i++)
|
||||
{
|
||||
GameObject product = null;
|
||||
yield return new WaitUntil(() =>
|
||||
{
|
||||
product = storeModel.GetProduct();
|
||||
return product != null;
|
||||
});
|
||||
product.transform.parent = productPos;
|
||||
product.transform.localPosition = Vector3.zero;
|
||||
product.transform.localRotation = Quaternion.identity;
|
||||
listProducts.Add(product);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (value.Contains(eventMove))
|
||||
{
|
||||
Debug.Log("MoveeventIncomming");
|
||||
|
||||
elapsedTime = 0;
|
||||
arrivalTime = GetJsonFloatValue(currentData, arrivalTimeKey);
|
||||
originalPos = transform.position;
|
||||
prevPos = transform.position;
|
||||
JArray originQueues = GetJsonArray(currentData, inputQueueKey);
|
||||
JArray originStores = GetJsonArray(currentData, inputStoreKey);
|
||||
string arrivalQueue = GetJsonValue(currentData, outputQueueKey)?.ToString();
|
||||
string arrivalStore = GetJsonValue(currentData, outputStoreKey)?.ToString();
|
||||
|
||||
if (originQueues != null && originQueues.HasValues)
|
||||
{
|
||||
string queueID = originQueues[0].ToString();
|
||||
SimulationModel model = DataManager.I.GetModel(queueID);
|
||||
SimulationModelStore storeModel = (SimulationModelStore)model;
|
||||
origin = storeModel.GetTransporterPosition();
|
||||
}
|
||||
else if ( originStores != null&& originStores.HasValues)
|
||||
{
|
||||
string storeID = originStores[0].ToString();
|
||||
SimulationModel model = DataManager.I.GetModel(storeID);
|
||||
SimulationModelStore storeModel = (SimulationModelStore)model;
|
||||
origin = storeModel.GetTransporterPosition();
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(arrivalQueue))
|
||||
{
|
||||
SimulationModel model = DataManager.I.GetModel(arrivalQueue);
|
||||
SimulationModelStore storeModel = (SimulationModelStore)model;
|
||||
destination = storeModel.GetTransporterPosition();
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(arrivalStore))
|
||||
{
|
||||
SimulationModel model = DataManager.I.GetModel(arrivalStore);
|
||||
SimulationModelStore storeModel = (SimulationModelStore)model;
|
||||
destination = storeModel.GetTransporterPosition();
|
||||
}
|
||||
}
|
||||
else if (value.Contains(eventUnloading))
|
||||
{
|
||||
yield return null;
|
||||
|
||||
string targetID = "";
|
||||
|
||||
if ( value.Contains("unloading_store"))
|
||||
{
|
||||
targetID = GetJsonValue(currentData, unloadStoreKey)?.ToString();
|
||||
}
|
||||
else if ( value.Contains("unloading_queue"))
|
||||
{
|
||||
targetID = GetJsonValue(currentData, unloadQueueKey)?.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
string[] tmpValue = { "data", "output_queue" };
|
||||
|
||||
targetID = GetJsonValue(currentData, tmpValue)?.ToString();
|
||||
}
|
||||
|
||||
SimulationModel model = new SimulationModel();
|
||||
model = DataManager.I.GetModel(targetID);
|
||||
SimulationModelStore storeModel = (SimulationModelStore)model;
|
||||
|
||||
if (listProducts.Count > 0)
|
||||
{
|
||||
GameObject product = listProducts[0];
|
||||
storeModel.StoreProduct(product);
|
||||
listProducts.Remove(product);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("Trying to unload from empty transporter : " + nodeID);
|
||||
}
|
||||
}
|
||||
else if (value.Contains(eventSpeed))
|
||||
{
|
||||
float originalTime = GetJsonFloatValue(currentData, originalTimeKey);
|
||||
float adjustedTime = GetJsonFloatValue(currentData, adjustedTimeKey);
|
||||
arrivalTime += adjustedTime - originalTime;
|
||||
elapsedTime = 0;
|
||||
originalPos = transform.position;
|
||||
prevPos = transform.position;
|
||||
}
|
||||
else if (value.Contains(eventReturning))
|
||||
{
|
||||
elapsedTime = 0;
|
||||
arrivalTime = GetJsonFloatValue(currentData, returnTimeKey);
|
||||
originalPos = transform.position;
|
||||
prevPos = transform.position;
|
||||
if (origin != null)
|
||||
{
|
||||
destination = origin;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
*/
|
||||
public override void GetData(string data)
|
||||
{
|
||||
var wrapclass = JsonConvert.DeserializeObject<SimulationDefaultJson>(data);
|
||||
|
||||
@@ -191,114 +191,6 @@ public class SimulationModelProcess : SimulationModel
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
protected override IEnumerator RunSimulationCoroutine()
|
||||
{
|
||||
yield return new WaitUntil(() => !string.IsNullOrEmpty(nodeID));
|
||||
while (dataQueue == null)
|
||||
{
|
||||
dataQueue = MQTTDataBase.Instance.GetDataQueue(nodeID);
|
||||
if (dataQueue == null)
|
||||
yield return null;
|
||||
else
|
||||
break;
|
||||
}
|
||||
while (true)
|
||||
{
|
||||
if (dataQueue.IsEmpty)
|
||||
{
|
||||
yield return null;
|
||||
continue;
|
||||
}
|
||||
if (dataQueue.TryDequeue(out JObject currentData))
|
||||
{
|
||||
string eventKey = "_event";
|
||||
if (currentData.ContainsKey(eventKey))
|
||||
{
|
||||
string value = currentData[eventKey].ToString();
|
||||
if (value.Contains(eventUsingQueue))
|
||||
{
|
||||
string[] queueIDKey = { "data", "queue_name" };
|
||||
string[] loadCountKey = { "data", "required_items" };
|
||||
string queueID = GetJsonValue(currentData, queueIDKey)?.ToString();
|
||||
int loadCount = GetJsonIntValue(currentData, loadCountKey);
|
||||
SimulationModel model = DataManager.I.GetModel(queueID);
|
||||
SimulationModelStore storeModel = (SimulationModelStore)model;
|
||||
for (int i = 0; i < loadCount; i++)
|
||||
{
|
||||
GameObject product = null;
|
||||
yield return new WaitUntil(() => {
|
||||
product = storeModel.GetProduct();
|
||||
return product != null;
|
||||
});
|
||||
product.transform.parent = productPos;
|
||||
product.transform.localPosition = Vector3.zero;
|
||||
product.transform.localRotation = Quaternion.identity;
|
||||
listProducts.Add(product);
|
||||
}
|
||||
}
|
||||
else if (value.Contains(eventUsingStore))
|
||||
{
|
||||
string[] queueIDKey = { "data", "store_name" };
|
||||
string[] loadCountKey = { "data", "required_items" };
|
||||
string queueID = GetJsonValue(currentData, queueIDKey)?.ToString();
|
||||
int loadCount = GetJsonIntValue(currentData, loadCountKey);
|
||||
SimulationModel model = DataManager.I.GetModel(queueID);
|
||||
SimulationModelStore storeModel = (SimulationModelStore)model;
|
||||
for (int i = 0; i < loadCount; i++)
|
||||
{
|
||||
GameObject product = null;
|
||||
yield return new WaitUntil(() => {
|
||||
product = storeModel.GetProduct();
|
||||
return product != null;
|
||||
});
|
||||
product.transform.parent = productPos;
|
||||
product.transform.localPosition = Vector3.zero;
|
||||
product.transform.localRotation = Quaternion.identity;
|
||||
listProducts.Add(product);
|
||||
}
|
||||
}
|
||||
else if (value.Contains(eventStartBatch))
|
||||
{
|
||||
string[] productCountKey = { "data", "product_count" };
|
||||
string[] processTimeKey = { "data", "processing_time" };
|
||||
int productCount = GetJsonIntValue(currentData, productCountKey);
|
||||
processTime = GetJsonFloatValue(currentData, processTimeKey);
|
||||
elapsedTime = 0;
|
||||
startBatch = true;
|
||||
onProcessStart?.Invoke();
|
||||
}
|
||||
else if (value.Contains(eventOutputQueue))
|
||||
{
|
||||
string[] outputQueueKey = { "data", "queue_name" };
|
||||
string[] productCountKey = { "data", "products_to_add" };
|
||||
string queueID = GetJsonValue(currentData, outputQueueKey)?.ToString();
|
||||
int productCount = GetJsonIntValue(currentData, productCountKey);
|
||||
SimulationModel model = DataManager.I.GetModel(queueID);
|
||||
SimulationModelStore storeModel = (SimulationModelStore)model;
|
||||
for (int i = 0; i < productCount; i++)
|
||||
{
|
||||
if (listProducts.Count > 0)
|
||||
{
|
||||
GameObject product = listProducts[0];
|
||||
storeModel.StoreProduct(product);
|
||||
listProducts.Remove(product);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("Trying to unload from empty transporter : " + nodeID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
*/
|
||||
|
||||
private void SetUsingQueue(ProcessDataClass_using_queue data)
|
||||
{
|
||||
string queueID = data.queue_name;
|
||||
|
||||
Reference in New Issue
Block a user