agv . mqtt 연동작업
This commit is contained in:
@@ -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}
|
||||
@@ -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<string, Dictionary<string, string>>();
|
||||
foreach (JObject obj in jarray.Children())
|
||||
|
||||
@@ -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<string, Dictionary<string, EventHandler<StudioServiceIdEventArgs>>>();
|
||||
listenerTypeMap = new Dictionary<string, EventHandler<StudioServiceTypeEventArgs>>();
|
||||
|
||||
|
||||
repository.OnTopicList += OnTopicList;
|
||||
// repository.OnDetectedError += OnDetectedError;
|
||||
@@ -77,7 +80,6 @@ namespace Studio
|
||||
{
|
||||
repository.Subscribe(topic);
|
||||
}
|
||||
//Que에 담아둔다?
|
||||
private void OnTopicList(string type, Dictionary<string, Dictionary<string, string>> entities)
|
||||
{
|
||||
foreach (var idKey in entities)
|
||||
@@ -86,22 +88,19 @@ namespace Studio
|
||||
}
|
||||
}
|
||||
|
||||
private async Task UpdateTopicData(string type, string id, Dictionary<string, string> entity)
|
||||
private void UpdateTopicData(string type, string id, Dictionary<string, string> 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<StudioServiceIdEventArgs> listener)
|
||||
public void AddTypeIdListener(string type, string id = null, EventHandler<StudioServiceIdEventArgs> 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<string, Dictionary<string, string>>();
|
||||
data.Add(id, entity);
|
||||
if (entity == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
DispatchTypeMachineEvent(type, data);
|
||||
}
|
||||
}
|
||||
|
||||
private void DispatchTypeMachineEvent(string type, Dictionary<string,Dictionary<string, string>> entities)
|
||||
|
||||
Reference in New Issue
Block a user