wjdakf aksgdmsdlfemfdl dlTDJTdj

This commit is contained in:
2025-06-24 17:02:07 +09:00
parent e5324ab48f
commit e936af0d5c
57 changed files with 2664 additions and 908 deletions

View File

@@ -1,73 +0,0 @@
using Newtonsoft.Json.Linq;
using System.Collections.Concurrent;
using UnityEngine;
using System.Collections;
using Octopus.Simulator.Networks;
public class SimulationModelSink : SimulationModel
{
public string eventShipItem = "items_shipped_successfully";
public string eventRemoveItem = "item_removed_from_queue";
public int totalShipped = 0;
ConcurrentQueue<JObject> dataQueue;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
}
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(eventShipItem))
{
}
else if (value.Contains(eventRemoveItem))
{
string[] queueIDKey = { "data", "queue_name" };
string[] queueRemainKey = { "data", "remaining_queue_length" };
string queueID = GetJsonValue(currentData, queueIDKey)?.ToString();
int queueCapacity = GetJsonIntValue(currentData, queueRemainKey);
SimulationModel model = DataManager.I.GetModel(queueID);
SimulationModelStore storeModel = (SimulationModelStore)model;
while (storeModel.storedProducts.Count > queueCapacity)
{
//Destroy(storeModel.GetProduct());
totalShipped++;
yield return null;
}
}
}
}
yield return null;
}
yield return null;
}
}