Commit 945f1ef1 authored by 潘梓豪's avatar 潘梓豪

Merge branch 'master' of git@gitlab.sd-zeus.com:yangzeyu/SCVerificationPipelineDT.git

# Conflicts:
#	Assets/Scripts/Components/AGV/LoginManager.cs
parents 3ca4f7ee 871fad6b
...@@ -39,14 +39,14 @@ public class LoginManager : MonoBehaviour ...@@ -39,14 +39,14 @@ public class LoginManager : MonoBehaviour
private void Awake() private void Awake()
{ {
OnReceiveMsg.AddListener(_getData); OnReceiveMsg.AddListener(_getData);
//StartCoroutine(GetJson()); StartCoroutine(GetJson());
} }
private void Start() private void Start()
{ {
//StartCoroutine(GetPositionData()); StartCoroutine(GetPositionData());
//StartCoroutine(FaultInformation()); StartCoroutine(FaultInformation());
//StartCoroutine(GetThreeModelSensorData()); StartCoroutine(GetThreeModelSensorData());
} }
public void StartLogin() public void StartLogin()
...@@ -86,9 +86,11 @@ public class LoginManager : MonoBehaviour ...@@ -86,9 +86,11 @@ public class LoginManager : MonoBehaviour
{ {
while (true) while (true)
{ {
if (!String.IsNullOrEmpty(productionlineID.text))
{
using (UnityWebRequest request = UnityWebRequest.Get(productionlineID.text)) using (UnityWebRequest request = UnityWebRequest.Get(productionlineID.text))
{ {
Debug.Log(productionlineID.text);
// 设置请求头 // 设置请求头
request.SetRequestHeader("Content-Type", "application/json"); request.SetRequestHeader("Content-Type", "application/json");
...@@ -106,12 +108,12 @@ public class LoginManager : MonoBehaviour ...@@ -106,12 +108,12 @@ public class LoginManager : MonoBehaviour
Debug.Log("Response: " + responseJson); Debug.Log("Response: " + responseJson);
// 使用 JsonUtility 解析 JSON 数据 // 使用 JsonUtility 解析 JSON 数据
positionData = JsonUtility.FromJson<RobotPositionData>(responseJson); positionData = JsonMapper.ToObject<RobotPositionData>(responseJson);
OnReceiveMsg.Invoke(positionData, "RobotPositionData"); OnReceiveMsg.Invoke(positionData, "RobotPositionData");
IsDataLoaded = true; IsDataLoaded = true;
} }
} }
}
yield return new WaitForSeconds(1); yield return new WaitForSeconds(1);
} }
} }
...@@ -121,6 +123,8 @@ public class LoginManager : MonoBehaviour ...@@ -121,6 +123,8 @@ public class LoginManager : MonoBehaviour
string jsonData = "{\"lineId\":\"" + lineID.text + "\"}"; string jsonData = "{\"lineId\":\"" + lineID.text + "\"}";
while (true) while (true)
{
if (!String.IsNullOrEmpty(faultInterface.text))
{ {
using (UnityWebRequest request = UnityWebRequest.PostWwwForm(faultInterface.text, jsonData)) using (UnityWebRequest request = UnityWebRequest.PostWwwForm(faultInterface.text, jsonData))
{ {
...@@ -144,7 +148,7 @@ public class LoginManager : MonoBehaviour ...@@ -144,7 +148,7 @@ public class LoginManager : MonoBehaviour
string responseJson = request.downloadHandler.text; string responseJson = request.downloadHandler.text;
// 使用 JsonUtility 解析 JSON 数据 // 使用 JsonUtility 解析 JSON 数据
faultData = JsonUtility.FromJson<FaultEventData>(responseJson); faultData = JsonMapper.ToObject<FaultEventData>(responseJson);
// 检查是否成功拿到数据 // 检查是否成功拿到数据
...@@ -159,6 +163,7 @@ public class LoginManager : MonoBehaviour ...@@ -159,6 +163,7 @@ public class LoginManager : MonoBehaviour
} }
} }
} }
}
yield return new WaitForSeconds(5f); yield return new WaitForSeconds(5f);
} }
} }
...@@ -166,6 +171,8 @@ public class LoginManager : MonoBehaviour ...@@ -166,6 +171,8 @@ public class LoginManager : MonoBehaviour
private IEnumerator GetThreeModelSensorData() private IEnumerator GetThreeModelSensorData()
{ {
while (true) while (true)
{
if (!String.IsNullOrEmpty(post_url.text))
{ {
using (UnityWebRequest request = UnityWebRequest.Get(post_url.text + "?lineId=" + lineID.text)) using (UnityWebRequest request = UnityWebRequest.Get(post_url.text + "?lineId=" + lineID.text))
{ {
...@@ -190,6 +197,7 @@ public class LoginManager : MonoBehaviour ...@@ -190,6 +197,7 @@ public class LoginManager : MonoBehaviour
} }
} }
} }
}
yield return new WaitForSeconds(1f); yield return new WaitForSeconds(1f);
} }
} }
...@@ -267,11 +275,13 @@ public class LoginManager : MonoBehaviour ...@@ -267,11 +275,13 @@ public class LoginManager : MonoBehaviour
rq.SetRequestHeader("Access-Control-Allow-Origin", "*"); rq.SetRequestHeader("Access-Control-Allow-Origin", "*");
rq.SetRequestHeader("Accept", "*"); rq.SetRequestHeader("Accept", "*");
yield return rq.SendWebRequest(); yield return rq.SendWebRequest();
if (string.IsNullOrEmpty(rq.error)) if (string.IsNullOrEmpty(rq.error))
{ {
try try
{ {
inputFieldData = JsonMapper.ToObject<InputFieldData>(rq.downloadHandler.text); inputFieldData = JsonMapper.ToObject<InputFieldData>(rq.downloadHandler.text);
Debug.Log(rq.downloadHandler.text);
if (IsLine1) if (IsLine1)
{ {
productionlineID.text = inputFieldData.productionlineID1; productionlineID.text = inputFieldData.productionlineID1;
......
...@@ -5,7 +5,7 @@ EditorBuildSettings: ...@@ -5,7 +5,7 @@ EditorBuildSettings:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
serializedVersion: 2 serializedVersion: 2
m_Scenes: m_Scenes:
- enabled: 1 - enabled: 0
path: Assets/_Scenes/1_Main.unity path: Assets/_Scenes/1_Main.unity
guid: a1193329f89803b4f8a14f6c0b15d2c1 guid: a1193329f89803b4f8a14f6c0b15d2c1
- enabled: 0 - enabled: 0
...@@ -14,7 +14,7 @@ EditorBuildSettings: ...@@ -14,7 +14,7 @@ EditorBuildSettings:
- enabled: 0 - enabled: 0
path: Assets/_Scenes/3_Main.unity path: Assets/_Scenes/3_Main.unity
guid: 20c0c67e1155d7340be70873c2eb30f1 guid: 20c0c67e1155d7340be70873c2eb30f1
- enabled: 0 - enabled: 1
path: Assets/_Scenes/4_Main.unity path: Assets/_Scenes/4_Main.unity
guid: da74b35adf3770040b51552fc0cb9a98 guid: da74b35adf3770040b51552fc0cb9a98
- enabled: 0 - enabled: 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment