Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
山
山西检定流水线数字孪生项目
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨泽宇
山西检定流水线数字孪生项目
Commits
0d6be671
Commit
0d6be671
authored
Aug 19, 2024
by
杨泽宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新
parent
d6df2803
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
488 additions
and
25 deletions
+488
-25
LoginManager.cs
Assets/Scripts/Components/AGV/LoginManager.cs
+49
-6
1_Main.unity
Assets/_Scenes/1_Main.unity
+432
-19
设置产线接口UI.prefab
Assets/_预设/UI/设置产线接口UI.prefab
+0
-0
设置产线接口UI.prefab.meta
Assets/_预设/UI/设置产线接口UI.prefab.meta
+7
-0
No files found.
Assets/Scripts/Components/AGV/LoginManager.cs
View file @
0d6be671
...
...
@@ -2,17 +2,15 @@ using System.Collections;
using
UnityEngine.Networking
;
using
UnityEngine
;
using
TMPro
;
using
System.IO
;
public
class
LoginManager
:
MonoBehaviour
{
public
TMP_InputField
productionlineID
;
public
string
ProductionlineID
;
public
TMP_InputField
faultInterface
;
public
string
FaultInterface
;
public
TMP_InputField
lineID
;
public
string
LineID
;
private
RobotPositionData
positionData
;
private
FaultEventData
faultData
;
...
...
@@ -31,6 +29,7 @@ public class LoginManager : MonoBehaviour
private
void
Awake
()
{
OnReceiveMsg
.
AddListener
(
_getData
);
LoadInputFields
();
// 在 Awake 中加载输入字段
}
private
void
Start
()
...
...
@@ -41,6 +40,7 @@ public class LoginManager : MonoBehaviour
public
void
StartLogin
()
{
SaveInputFields
();
StartCoroutine
(
GetPositionData
());
StartCoroutine
(
FaultInformation
());
}
...
...
@@ -76,7 +76,7 @@ public class LoginManager : MonoBehaviour
while
(
true
)
{
using
(
UnityWebRequest
request
=
UnityWebRequest
.
Get
(
ProductionlineID
))
using
(
UnityWebRequest
request
=
UnityWebRequest
.
Get
(
productionlineID
.
text
))
{
// 设置请求头
request
.
SetRequestHeader
(
"Content-Type"
,
"application/json"
);
...
...
@@ -106,11 +106,11 @@ public class LoginManager : MonoBehaviour
private
IEnumerator
FaultInformation
()
{
string
jsonData
=
"{\"lineId\":\""
+
LineID
+
"\"}"
;
string
jsonData
=
"{\"lineId\":\""
+
lineID
.
text
+
"\"}"
;
while
(
true
)
{
using
(
UnityWebRequest
request
=
UnityWebRequest
.
PostWwwForm
(
FaultInterface
,
jsonData
))
using
(
UnityWebRequest
request
=
UnityWebRequest
.
PostWwwForm
(
faultInterface
.
text
,
jsonData
))
{
// 设置请求头
request
.
SetRequestHeader
(
"Content-Type"
,
"application/json"
);
...
...
@@ -150,6 +150,49 @@ public class LoginManager : MonoBehaviour
yield
return
new
WaitForSeconds
(
5f
);
}
}
public
void
SaveInputFields
()
{
InputFieldData
data
=
new
InputFieldData
{
productionlineID
=
productionlineID
.
text
,
faultInterface
=
faultInterface
.
text
,
lineID
=
lineID
.
text
};
string
json
=
JsonUtility
.
ToJson
(
data
);
File
.
WriteAllText
(
Application
.
persistentDataPath
+
"/inputFields.json"
,
json
);
Debug
.
Log
(
"Input fields saved to JSON."
);
}
public
void
LoadInputFields
()
{
string
path
=
Application
.
persistentDataPath
+
"/inputFields.json"
;
if
(
File
.
Exists
(
path
))
{
string
json
=
File
.
ReadAllText
(
path
);
InputFieldData
data
=
JsonUtility
.
FromJson
<
InputFieldData
>(
json
);
productionlineID
.
text
=
data
.
productionlineID
;
faultInterface
.
text
=
data
.
faultInterface
;
lineID
.
text
=
data
.
lineID
;
Debug
.
Log
(
"Input fields loaded from JSON."
);
}
else
{
Debug
.
Log
(
"No saved input fields data found."
);
}
}
}
[System.Serializable]
public
class
InputFieldData
{
public
string
productionlineID
;
public
string
faultInterface
;
public
string
lineID
;
}
// 定义机器人位置数据结构
...
...
Assets/_Scenes/1_Main.unity
View file @
0d6be671
This diff is collapsed.
Click to expand it.
Assets/_预设/UI/设置产线接口UI.prefab
0 → 100644
View file @
0d6be671
This diff is collapsed.
Click to expand it.
Assets/_预设/UI/设置产线接口UI.prefab.meta
0 → 100644
View file @
0d6be671
fileFormatVersion: 2
guid: ed32f55596f4ce64e96fe9f95c481cc0
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment