webset
This commit is contained in:
@@ -56,7 +56,7 @@ namespace Octopus.Simulator
|
||||
panelConnectedObject.gameObject.SetActive(false);
|
||||
panelPlacedObject.gameObject.SetActive(false);
|
||||
LogicWindow.gameObject.SetActive(false);
|
||||
//FindAnyObjectByType<WebReceiver>().onParameterRecived += RequestInfo;
|
||||
FindAnyObjectByType<WebReceiver>().onParameterRecived += RequestInfo;
|
||||
FindAnyObjectByType<MQTTManager>().onLogicUpdated += RequestInfo;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Octopus.Simulator
|
||||
[Serializable]
|
||||
public class LogicInfo
|
||||
{
|
||||
public int status;
|
||||
public int? status=0;
|
||||
public string code;
|
||||
public string message;
|
||||
public LogicData data = new LogicData();
|
||||
@@ -22,7 +22,7 @@ namespace Octopus.Simulator
|
||||
[Serializable]
|
||||
public class SimulatorPostClass
|
||||
{
|
||||
public int status;
|
||||
public int? status=0;
|
||||
public string code;
|
||||
public string message;
|
||||
public SimulationData data = new SimulationData();
|
||||
@@ -33,7 +33,7 @@ namespace Octopus.Simulator
|
||||
[Serializable]
|
||||
public class SimulatorGetClass
|
||||
{
|
||||
public int status;
|
||||
public int? status=0;
|
||||
public string code;
|
||||
public string message;
|
||||
public SimulatorGetData data = new SimulatorGetData();
|
||||
@@ -56,10 +56,10 @@ namespace Octopus.Simulator
|
||||
[Serializable]
|
||||
public class LogicData
|
||||
{
|
||||
public int id;
|
||||
public int projectId;
|
||||
public int? id=0;
|
||||
public int? projectId=0;
|
||||
//public int logicId;
|
||||
public int userId;
|
||||
public int? userId=0;
|
||||
public string name;
|
||||
public string simulationCode;
|
||||
public logicData data;
|
||||
@@ -86,7 +86,7 @@ namespace Octopus.Simulator
|
||||
[SerializeReference]
|
||||
[JsonConverter(typeof(ComponentsConverter))]
|
||||
public List<ILogicComponent> components;
|
||||
public int simulation_time;
|
||||
public int? simulation_time=0;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
@@ -97,16 +97,16 @@ namespace Octopus.Simulator
|
||||
[Serializable]
|
||||
public class SimulationParameters
|
||||
{
|
||||
public int speed;
|
||||
public int duration;
|
||||
public int? speed=0;
|
||||
public int? duration=0;
|
||||
public bool real_time;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class HistoryParameters
|
||||
{
|
||||
public int projectId;
|
||||
public int logicId;
|
||||
public int? projectId=0;
|
||||
public int? logicId=0;
|
||||
public string logicData;
|
||||
public string name;
|
||||
}
|
||||
|
||||
@@ -45,10 +45,10 @@ namespace Octopus.Simulator.Networks
|
||||
void Awake()
|
||||
{
|
||||
mqttManager = this;
|
||||
SetMqttConfig();
|
||||
FindAnyObjectByType<WebReceiver>().onMqttConfigReceived += SetMqttConfig;
|
||||
}
|
||||
|
||||
private void SetMqttConfig()
|
||||
public void SetMqttConfig(string json)
|
||||
{
|
||||
/*
|
||||
string path = Application.streamingAssetsPath + MQTTpath;
|
||||
@@ -57,13 +57,14 @@ namespace Octopus.Simulator.Networks
|
||||
{
|
||||
json = reader.ReadToEnd();
|
||||
}
|
||||
*/
|
||||
TextAsset json = Resources.Load<TextAsset>(MQTTpath);
|
||||
Debug.Log(json.text);
|
||||
MQTTConfigList ConfigList = JsonConvert.DeserializeObject<MQTTConfigList>(json.text);
|
||||
*/
|
||||
MQTTConfigList ConfigList = JsonConvert.DeserializeObject<MQTTConfigList>(json);
|
||||
var config = ConfigList.configs[0];
|
||||
string clientName = config.name;
|
||||
string host = config.host;
|
||||
Debug.Log($"client:{host}");
|
||||
int port = config.port;
|
||||
|
||||
Connect(clientName, host, port);
|
||||
@@ -123,6 +124,7 @@ namespace Octopus.Simulator.Networks
|
||||
private void OnMessage(MQTTClient client, SubscriptionTopic topic, string topicName, ApplicationMessage message)
|
||||
{
|
||||
var payload = Encoding.UTF8.GetString(message.Payload.Data, message.Payload.Offset, message.Payload.Count);
|
||||
Debug.Log(payload);
|
||||
if (payload.Contains("component_id"))
|
||||
{
|
||||
basemessage = JsonConvert.DeserializeObject<BaseSimulationMessage>(payload);
|
||||
|
||||
@@ -16,7 +16,7 @@ public class ProjectDataManager : MonoBehaviour
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
//FindAnyObjectByType<WebReceiver>().onParameterRecived += RequestInfo;
|
||||
FindAnyObjectByType<WebReceiver>().onParameterRecived += RequestInfo;
|
||||
projectMenuButton.onClick.AddListener(SetActive);
|
||||
}
|
||||
public void RequestInfo()
|
||||
|
||||
@@ -32,11 +32,12 @@ namespace Octopus.Simulator.Networks
|
||||
void Awake()
|
||||
{
|
||||
webManager = this;
|
||||
SetWebConfig();
|
||||
SetApiConfig();
|
||||
FindAnyObjectByType<WebReceiver>().onWebConfigReceived += SetWebConfig;
|
||||
//SetWebConfig();
|
||||
SetApiConfig();
|
||||
}
|
||||
|
||||
private void SetWebConfig()
|
||||
private void SetWebConfig(string json)
|
||||
{
|
||||
/*
|
||||
string path = Application.streamingAssetsPath + WebPath;
|
||||
@@ -45,11 +46,12 @@ namespace Octopus.Simulator.Networks
|
||||
{
|
||||
json = reader.ReadToEnd();
|
||||
}
|
||||
var json = Resources.Load<TextAsset>(WebPath)
|
||||
*/
|
||||
var json = Resources.Load<TextAsset>(WebPath);
|
||||
WebConfigList ConfigList = JsonConvert.DeserializeObject<WebConfigList>(json.text);
|
||||
WebConfigList ConfigList = JsonConvert.DeserializeObject<WebConfigList>(json);
|
||||
var config = ConfigList.configs[0];
|
||||
host = config.host;
|
||||
Debug.Log($"host:{host}");
|
||||
port = config.port;
|
||||
token = config.accessToken;
|
||||
http = $"{host}:{port}";
|
||||
|
||||
@@ -4,20 +4,27 @@ using System;
|
||||
using TMPro;
|
||||
using Octopus.Simulator.Networks;
|
||||
using Octopus.Simulator;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public class WebReceiver : MonoBehaviour
|
||||
{
|
||||
public SimulatorConfig config;
|
||||
public event Action onParameterRecived;
|
||||
public event Action<string> onMqttConfigReceived;
|
||||
public event Action<string> onWebConfigReceived;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
Application.ExternalCall("loadingComplete");
|
||||
/*
|
||||
config.projectId = "17";
|
||||
//config.simulationId = "15";
|
||||
config.logicId = "25";
|
||||
WebParameters.config = config;
|
||||
onParameterRecived += FindAnyObjectByType<ProjectDataManager>().RequestInfo;
|
||||
onParameterRecived += FindAnyObjectByType<LogicDataManager>().RequestInfo;
|
||||
//onParameterRecived += FindAnyObjectByType<ProjectDataManager>().RequestInfo;
|
||||
//onParameterRecived += FindAnyObjectByType<LogicDataManager>().RequestInfo;
|
||||
onParameterRecived?.Invoke();
|
||||
*/
|
||||
}
|
||||
|
||||
public void ReceiveWebParameterJson(string json)
|
||||
@@ -25,5 +32,18 @@ public class WebReceiver : MonoBehaviour
|
||||
config = JsonConvert.DeserializeObject<SimulatorConfig>(json);
|
||||
WebParameters.config = config;
|
||||
onParameterRecived?.Invoke();
|
||||
Debug.Log($"webparam:{json}");
|
||||
}
|
||||
|
||||
public void ReceiveMQTTConfigJson(string json)
|
||||
{
|
||||
onMqttConfigReceived?.Invoke(json);
|
||||
Debug.Log($"mqttconfig:{json}");
|
||||
}
|
||||
|
||||
public void ReceiveWebConfigJson(string json)
|
||||
{
|
||||
onWebConfigReceived?.Invoke(json);
|
||||
Debug.Log($"webconfig:{json}");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user