diff --git a/Assets/Prefabs/AGV/AGV 1.prefab b/Assets/Resources/TestAGV.prefab similarity index 98% rename from Assets/Prefabs/AGV/AGV 1.prefab rename to Assets/Resources/TestAGV.prefab index e07935be..e2217d08 100644 --- a/Assets/Prefabs/AGV/AGV 1.prefab +++ b/Assets/Resources/TestAGV.prefab @@ -9,9 +9,9 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 421374873455346910} - - component: {fileID: 5492482365278483619} + - component: {fileID: 802422837581587047} m_Layer: 0 - m_Name: AGV 1 + m_Name: TestAGV m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -34,7 +34,7 @@ Transform: - {fileID: 1627652318861080814} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &5492482365278483619 +--- !u!114 &802422837581587047 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} diff --git a/Assets/Prefabs/AGV/AGV 1.prefab.meta b/Assets/Resources/TestAGV.prefab.meta similarity index 100% rename from Assets/Prefabs/AGV/AGV 1.prefab.meta rename to Assets/Resources/TestAGV.prefab.meta diff --git a/Assets/Scripts/Studio/Connect/StudioRepoistory.cs b/Assets/Scripts/Studio/Connect/StudioRepoistory.cs index 3a0fed9b..4900919e 100644 --- a/Assets/Scripts/Studio/Connect/StudioRepoistory.cs +++ b/Assets/Scripts/Studio/Connect/StudioRepoistory.cs @@ -89,6 +89,7 @@ namespace Studio } } + private void OnStateChangedMQTT(MQTTClient client, ClientStates oldState, ClientStates newState) { Debug.Log($"{oldState} => {newState}"); @@ -132,13 +133,12 @@ namespace Studio { string key = prop.Name.ToString(); string value = prop.Value.ToString(); - // Debug.Log($"kEY : {key}, Value:{value}"); } var T = json["data"]; var split = T.ToString().Split('['); var t = $"[{split[1]}"; - //Debug.Log(T.ToString()); + JArray jarray = JArray.Parse(t); var list = new Dictionary>(); foreach (JObject obj in jarray.Children()) diff --git a/Assets/Scripts/Studio/Connect/StudioService.cs b/Assets/Scripts/Studio/Connect/StudioService.cs index 5643adb8..1d151bca 100644 --- a/Assets/Scripts/Studio/Connect/StudioService.cs +++ b/Assets/Scripts/Studio/Connect/StudioService.cs @@ -3,6 +3,7 @@ using Studio.Setting.Connect; using System; using System.Collections.Generic; using System.Threading.Tasks; +using System.Threading; using UnityEngine; using XED; @@ -64,6 +65,8 @@ namespace Studio { this.repository = repository; listenerIdMap = new Dictionary>>(); + listenerTypeMap = new Dictionary>(); + repository.OnTopicList += OnTopicList; // repository.OnDetectedError += OnDetectedError; @@ -77,7 +80,6 @@ namespace Studio { repository.Subscribe(topic); } - //Que에 담아둔다? private void OnTopicList(string type, Dictionary> entities) { foreach (var idKey in entities) @@ -86,22 +88,19 @@ namespace Studio } } - private async Task UpdateTopicData(string type, string id, Dictionary entity) + private void UpdateTopicData(string type, string id, Dictionary entity) { if (!updateTime.ContainsKey(type)) updateTime.Add(type, 0.5f); var time = updateTime[type]; - - var task = Task.Run(async () => + var task = Task.Factory.StartNew(async () => { - var st = string.Empty; - st = $"{type}:"; int delayTime = (int)(time * 1000); await Task.Delay(delayTime); DispatchMachineEvent(type, id, entity); - }); + },CancellationToken.None, TaskCreationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); } @@ -124,12 +123,13 @@ namespace Studio return result != null; } - public void AddTypeIdListener(string type, string id, EventHandler listener) + public void AddTypeIdListener(string type, string id = null, EventHandler listener=null) { if (!listenerIdMap.ContainsKey(type)) { listenerIdMap.Add(type, new()); - //Debug.LogError($"Key Value is missing!!!! -Key:{type}-"); + Debug.Log("딱한번들어옴"); + return; } if (!listenerIdMap[type].ContainsKey(id)) { @@ -160,13 +160,11 @@ namespace Studio var t = sw.ElapsedMilliseconds; - if (data.State.Equals(APIState.Loaded)) { if (!baseData.ContainsKey(url)) baseData.Add(url, new()); - CheckAPIBoarder(data.Entity.ToString(), data.ReqSize, url, t); UpdateEntity(url, data.Entity.ToString()); } @@ -214,7 +212,6 @@ namespace Studio boardEntity.MaximumResponsePacketAPI = maxResponseApi; boardEntity.MaximumResponseTimeAPI = maxResponseTimeApi; return boardEntity; - //JsonUtility.ToJson() } public void UpdateEntity(string type, string data) @@ -242,7 +239,6 @@ namespace Studio keyvalue.Add(key, value); } list.Add(keyvalue); - //DispatchMachineEvent(type, id, keyvalue); } } @@ -250,12 +246,22 @@ namespace Studio { if (!listenerIdMap.ContainsKey(type)) { - Debug.LogError($"Key Value is missing!!!! -Key:{type}-"); + Debug.Log($"Key Value is missing!!!! -Key:{type}-"); } if (listenerIdMap[type].ContainsKey(id)) { listenerIdMap[type][id].Invoke(this, new StudioServiceIdEventArgs(type, entity)); } + else + { + var data = new Dictionary>(); + data.Add(id, entity); + if (entity == null) + { + return; + } + DispatchTypeMachineEvent(type, data); + } } private void DispatchTypeMachineEvent(string type, Dictionary> entities)