From 5ab0270392b23c4775f366834d44b51dc5741e2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A4=80=ED=95=99=20=EB=85=B8?= Date: Fri, 23 May 2025 14:41:31 +0900 Subject: [PATCH 1/2] =?UTF-8?q?agv=20=ED=85=8C=EC=8A=A4=ED=8A=B8=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Prefabs/AGV/AGV 1.prefab | 238 ++++++++++++++++++ Assets/Prefabs/AGV/AGV 1.prefab.meta | 7 + .../AutoFactory/VirtualFactoryManager.cs | 4 +- .../Scripts/Studio/Connect/StudioService.cs | 69 +++-- Assets/Scripts/Studio/Machine/AGV/AGV.cs | 4 +- .../Scripts/Studio/Machine/AGV/AGVManager.cs | 12 +- Assets/Scripts/Studio/Machine/DataReader.cs | 5 +- Assets/TMPFolder/Modal/UIModalManager.cs | 4 +- Assets/TMPFolder/Popup/UIAlertManager.cs | 4 +- Assets/TMPFolder/Popup/UIPopupManager.cs | 4 +- Assets/TMPFolder/RJHTest.cs | 2 +- 11 files changed, 316 insertions(+), 37 deletions(-) create mode 100644 Assets/Prefabs/AGV/AGV 1.prefab create mode 100644 Assets/Prefabs/AGV/AGV 1.prefab.meta diff --git a/Assets/Prefabs/AGV/AGV 1.prefab b/Assets/Prefabs/AGV/AGV 1.prefab new file mode 100644 index 00000000..e07935be --- /dev/null +++ b/Assets/Prefabs/AGV/AGV 1.prefab @@ -0,0 +1,238 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &1505508720499862715 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 421374873455346910} + - component: {fileID: 5492482365278483619} + m_Layer: 0 + m_Name: AGV 1 + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &421374873455346910 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1505508720499862715} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 3909547189796084948} + - {fileID: 1627652318861080814} + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &5492482365278483619 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1505508720499862715} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 84ad40885a5aaa04e85eb7de0489cc8d, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!1 &4488530822671186643 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1627652318861080814} + - component: {fileID: 5506305391979457121} + - component: {fileID: 4473865689154435547} + m_Layer: 0 + m_Name: Sensor + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1627652318861080814 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4488530822671186643} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 421374873455346910} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!135 &5506305391979457121 +SphereCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4488530822671186643} + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_IsTrigger: 1 + m_ProvidesContacts: 0 + m_Enabled: 1 + serializedVersion: 3 + m_Radius: 10 + m_Center: {x: 0, y: 0, z: 0} +--- !u!114 &4473865689154435547 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4488530822671186643} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a65fe5e7ae0d6a74dbe40d269a1cb6f7, type: 3} + m_Name: + m_EditorClassIdentifier: + obstacleLayer: + serializedVersion: 2 + m_Bits: 256 +--- !u!1 &7175446550791974323 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 8278436267998297966} + m_Layer: 0 + m_Name: Pallet_Socket + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &8278436267998297966 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7175446550791974323} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 7020894527220248915} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1001 &154300052577553464 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + serializedVersion: 3 + m_TransformParent: {fileID: 421374873455346910} + m_Modifications: + - target: {fileID: 3775616689855107308, guid: 586ca79ec44844746b347929276fc0e6, type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3775616689855107308, guid: 586ca79ec44844746b347929276fc0e6, type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3775616689855107308, guid: 586ca79ec44844746b347929276fc0e6, type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3775616689855107308, guid: 586ca79ec44844746b347929276fc0e6, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 3775616689855107308, guid: 586ca79ec44844746b347929276fc0e6, type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3775616689855107308, guid: 586ca79ec44844746b347929276fc0e6, type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3775616689855107308, guid: 586ca79ec44844746b347929276fc0e6, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3775616689855107308, guid: 586ca79ec44844746b347929276fc0e6, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3775616689855107308, guid: 586ca79ec44844746b347929276fc0e6, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3775616689855107308, guid: 586ca79ec44844746b347929276fc0e6, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4046099219731300723, guid: 586ca79ec44844746b347929276fc0e6, type: 3} + propertyPath: m_Name + value: Palletrobot + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_RemovedGameObjects: [] + m_AddedGameObjects: + - targetCorrespondingSourceObject: {fileID: 7154835845995298155, guid: 586ca79ec44844746b347929276fc0e6, type: 3} + insertIndex: -1 + addedObject: {fileID: 8278436267998297966} + m_AddedComponents: + - targetCorrespondingSourceObject: {fileID: 6070737613420926900, guid: 586ca79ec44844746b347929276fc0e6, type: 3} + insertIndex: -1 + addedObject: {fileID: 5083700428396174471} + m_SourcePrefab: {fileID: 100100000, guid: 586ca79ec44844746b347929276fc0e6, type: 3} +--- !u!4 &3909547189796084948 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 3775616689855107308, guid: 586ca79ec44844746b347929276fc0e6, type: 3} + m_PrefabInstance: {fileID: 154300052577553464} + m_PrefabAsset: {fileID: 0} +--- !u!1 &6204755932358581132 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 6070737613420926900, guid: 586ca79ec44844746b347929276fc0e6, type: 3} + m_PrefabInstance: {fileID: 154300052577553464} + m_PrefabAsset: {fileID: 0} +--- !u!114 &5083700428396174471 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6204755932358581132} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5fb7059a769257346badd43882bceb27, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!4 &7020894527220248915 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 7154835845995298155, guid: 586ca79ec44844746b347929276fc0e6, type: 3} + m_PrefabInstance: {fileID: 154300052577553464} + m_PrefabAsset: {fileID: 0} diff --git a/Assets/Prefabs/AGV/AGV 1.prefab.meta b/Assets/Prefabs/AGV/AGV 1.prefab.meta new file mode 100644 index 00000000..ecca647f --- /dev/null +++ b/Assets/Prefabs/AGV/AGV 1.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 53db74a6e1101d2438a0c0083c5c232b +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Examples/AutoFactory/VirtualFactoryManager.cs b/Assets/Scripts/Examples/AutoFactory/VirtualFactoryManager.cs index 1481a1c4..e67f643b 100644 --- a/Assets/Scripts/Examples/AutoFactory/VirtualFactoryManager.cs +++ b/Assets/Scripts/Examples/AutoFactory/VirtualFactoryManager.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using UnityEditor; @@ -197,7 +197,7 @@ public class VirtualFactoryManager : MonoBehaviour agvWorker.onCompleteTask += OnAGVIdle; } - void OnAGVIdle(AGV worker) + void OnAGVIdle(Studio.VirtualFactory.AGV worker) { Debug.Log($"{worker.name} is On Enter idle"); stackerNeedsChecker.Scanning(); diff --git a/Assets/Scripts/Studio/Connect/StudioService.cs b/Assets/Scripts/Studio/Connect/StudioService.cs index 8d29b29e..5643adb8 100644 --- a/Assets/Scripts/Studio/Connect/StudioService.cs +++ b/Assets/Scripts/Studio/Connect/StudioService.cs @@ -8,15 +8,27 @@ using XED; namespace Studio { + public class StudioServiceIdEventArgs : EventArgs + { + public readonly string Type; + public Dictionary Entity; + + public StudioServiceIdEventArgs(string type, Dictionary entity) + { + Type = type; + Entity = entity; + } + } + public class StudioServiceTypeEventArgs : EventArgs { public readonly string Type; - Dictionary Entitis; + public Dictionary> Entitis; - public StudioServiceTypeEventArgs(string type, Dictionary entity) + public StudioServiceTypeEventArgs(string type, Dictionary> entitis) { Type = type; - Entitis = entity; + Entitis = entitis; } } @@ -28,27 +40,30 @@ namespace Studio static StudioService() { } #endregion - private Dictionary>> listenerIdMap; + private Dictionary>> listenerIdMap; + private Dictionary> listenerTypeMap; + private StudioRepoistory repository; private Dictionary updateTime = new(); + + #region 패킷계산 private int totalRequestPacket; private int totalResponsePacket; private long maxElapsedTime; private long totalElapsedTime; private int maxReponesSize; private int maxReuqestSize; - private string maxReuqestApi; private string maxResponseApi; private string maxResponseTimeApi; - - public Dictionary> baseData = new(); + #endregion + public Dictionary>>> baseData = new(); //private string private StudioService(StudioRepoistory repository) { this.repository = repository; - listenerIdMap = new Dictionary>>(); + listenerIdMap = new Dictionary>>(); repository.OnTopicList += OnTopicList; // repository.OnDetectedError += OnDetectedError; @@ -109,7 +124,7 @@ namespace Studio return result != null; } - public void AddTypeListener(string type, string id, EventHandler listener) + public void AddTypeIdListener(string type, string id, EventHandler listener) { if (!listenerIdMap.ContainsKey(type)) { @@ -125,7 +140,17 @@ namespace Studio listenerIdMap[type][id] += listener; } } - + public void AddTypeListener(string type, EventHandler listener) + { + if (!listenerTypeMap.ContainsKey(type)) + { + listenerTypeMap[type] = listener; + } + else + { + listenerTypeMap[type] += listener; + } + } public async Task LoadBaseData(string url) { System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); @@ -142,7 +167,6 @@ namespace Studio baseData.Add(url, new()); - baseData[url] = data; CheckAPIBoarder(data.Entity.ToString(), data.ReqSize, url, t); UpdateEntity(url, data.Entity.ToString()); } @@ -205,24 +229,20 @@ namespace Studio } var datas = json["rows"].ToString(); + var list = new List>(); JArray jarray = JArray.Parse(datas); foreach (JObject obj in jarray.Children()) { Dictionary keyvalue = new(); - int index = 0; string id = string.Empty; foreach (JProperty prop in obj.Children()) { string key = prop.Name.ToString(); string value = prop.Value.ToString(); - if (index == 0) - { - id = value; - index = 1; - } keyvalue.Add(key, value); } - DispatchMachineEvent(type, id, keyvalue); + list.Add(keyvalue); + //DispatchMachineEvent(type, id, keyvalue); } } @@ -234,9 +254,20 @@ namespace Studio } if (listenerIdMap[type].ContainsKey(id)) { - listenerIdMap[type][id].Invoke(this, new StudioServiceTypeEventArgs(type, entity)); + listenerIdMap[type][id].Invoke(this, new StudioServiceIdEventArgs(type, entity)); } } + private void DispatchTypeMachineEvent(string type, Dictionary> entities) + { + if (!listenerTypeMap.ContainsKey(type)) + { + Debug.LogError($"Key Value is missing!!!! -Key:{type}-"); + } + if (listenerTypeMap.ContainsKey(type)) + { + listenerTypeMap[type].Invoke(this, new(type, entities)); + } + } } } diff --git a/Assets/Scripts/Studio/Machine/AGV/AGV.cs b/Assets/Scripts/Studio/Machine/AGV/AGV.cs index 2bce7804..bda6d7f5 100644 --- a/Assets/Scripts/Studio/Machine/AGV/AGV.cs +++ b/Assets/Scripts/Studio/Machine/AGV/AGV.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using UnityEngine; @@ -340,5 +340,7 @@ namespace Studio.VirtualFactory { updateAction.Invoke(); } + + } } \ No newline at end of file diff --git a/Assets/Scripts/Studio/Machine/AGV/AGVManager.cs b/Assets/Scripts/Studio/Machine/AGV/AGVManager.cs index 2666271e..7248c502 100644 --- a/Assets/Scripts/Studio/Machine/AGV/AGVManager.cs +++ b/Assets/Scripts/Studio/Machine/AGV/AGVManager.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using UnityEngine; using Studio.VirtualFactory; @@ -8,17 +8,17 @@ namespace Studio.Manage { public class AGVManager : Manager { - public AGV prf_AGV; + public Studio.VirtualFactory.AGV prf_AGV; public AGVSpec prf_Spec; - public HashSet agvs = new(); + public HashSet agvs = new(); public bool autoIndexing; public override void Init() { - + } - public bool TryGetIdleAGV(out AGV result) + public bool TryGetIdleAGV(out Studio.VirtualFactory.AGV result) { //Debug.Log($"Try Get Idle AGV"); foreach (var agv in agvs) @@ -35,7 +35,7 @@ namespace Studio.Manage return false; } - public AGV CreateEmptyAGV() + public Studio.VirtualFactory.AGV CreateEmptyAGV() { var agv = UnityEngine.Object.Instantiate(prf_AGV); agvs.Add(agv); diff --git a/Assets/Scripts/Studio/Machine/DataReader.cs b/Assets/Scripts/Studio/Machine/DataReader.cs index ceeee33e..f38000ad 100644 --- a/Assets/Scripts/Studio/Machine/DataReader.cs +++ b/Assets/Scripts/Studio/Machine/DataReader.cs @@ -1,3 +1,4 @@ + using System.Collections; using System.Collections.Generic; using UnityEngine; @@ -39,7 +40,7 @@ public class DataReader : MonoBehaviour void Start() { //ReplayTimer.gameObject.SetActive(true); - // Resources ҷɴϴ. + // Resources 폴더에서 파일을 불러옵니다. csvFile = Resources.Load($"LogData/DataLog"); if (csvFile != null) @@ -51,7 +52,7 @@ public class DataReader : MonoBehaviour } else { - Debug.LogError("CSV ã ϴ."); + Debug.LogError("CSV 파일을 찾을 수 없습니다."); } } diff --git a/Assets/TMPFolder/Modal/UIModalManager.cs b/Assets/TMPFolder/Modal/UIModalManager.cs index 210e13c4..ffcafe7e 100644 --- a/Assets/TMPFolder/Modal/UIModalManager.cs +++ b/Assets/TMPFolder/Modal/UIModalManager.cs @@ -1,6 +1,6 @@ -using UnityEngine; +using Studio.Core; +using UnityEngine; using UnityEngine.SceneManagement; -using XED.Core; using XRLib; namespace Studio.UI.Modal diff --git a/Assets/TMPFolder/Popup/UIAlertManager.cs b/Assets/TMPFolder/Popup/UIAlertManager.cs index 3e7e47c8..99fce4b5 100644 --- a/Assets/TMPFolder/Popup/UIAlertManager.cs +++ b/Assets/TMPFolder/Popup/UIAlertManager.cs @@ -1,6 +1,6 @@ -using UnityEngine; +using Studio.Core; +using UnityEngine; using UnityEngine.SceneManagement; -using XED.Core; using XRLib; namespace Studio.UI.Popup diff --git a/Assets/TMPFolder/Popup/UIPopupManager.cs b/Assets/TMPFolder/Popup/UIPopupManager.cs index 40a16a6d..523fedb3 100644 --- a/Assets/TMPFolder/Popup/UIPopupManager.cs +++ b/Assets/TMPFolder/Popup/UIPopupManager.cs @@ -1,7 +1,7 @@ -using System; +using Studio.Core; +using System; using UnityEngine; using UnityEngine.SceneManagement; -using XED.Core; using XRLib; namespace Studio.UI.Popup diff --git a/Assets/TMPFolder/RJHTest.cs b/Assets/TMPFolder/RJHTest.cs index 34a92aa0..23bc1df9 100644 --- a/Assets/TMPFolder/RJHTest.cs +++ b/Assets/TMPFolder/RJHTest.cs @@ -11,7 +11,7 @@ namespace XED // Start is called once before the first execution of Update after the MonoBehaviour is created private StudioService tt; private int aa; - void Start() + void Awake() { Constants.MQTTDomain = "220.90.135.190"; Constants.APIDomain = "220.90.135.190"; From 9780c297e6ddeecc6c36e81a8edb549efa96d914 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A4=80=ED=95=99=20=EB=85=B8?= Date: Sat, 24 May 2025 14:11:29 +0900 Subject: [PATCH 2/2] =?UTF-8?q?agv=20.=20mqtt=20=EC=97=B0=EB=8F=99?= =?UTF-8?q?=EC=9E=91=EC=97=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AGV 1.prefab => Resources/TestAGV.prefab} | 6 ++-- .../TestAGV.prefab.meta} | 0 .../Studio/Connect/StudioRepoistory.cs | 4 +-- .../Scripts/Studio/Connect/StudioService.cs | 34 +++++++++++-------- 4 files changed, 25 insertions(+), 19 deletions(-) rename Assets/{Prefabs/AGV/AGV 1.prefab => Resources/TestAGV.prefab} (98%) rename Assets/{Prefabs/AGV/AGV 1.prefab.meta => Resources/TestAGV.prefab.meta} (100%) 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)