parent
eb710ad8be
commit
7fe89be50d
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 741582b0d3c129649a26e0b61e028e00
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,126 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &-1224730893789095258
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 11
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
version: 5
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: DisplayOrigin
|
||||
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap:
|
||||
RenderType: Opaque
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BaseMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _SpecGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_Lightmaps:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_LightmapsInd:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_ShadowMasks:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _AlphaClip: 0
|
||||
- _Blend: 0
|
||||
- _BumpScale: 1
|
||||
- _ClearCoatMask: 0
|
||||
- _ClearCoatSmoothness: 0
|
||||
- _Cull: 2
|
||||
- _Cutoff: 0.5
|
||||
- _DetailAlbedoMapScale: 1
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _EnvironmentReflections: 1
|
||||
- _GlossMapScale: 0
|
||||
- _Glossiness: 0
|
||||
- _GlossyReflections: 0
|
||||
- _Metallic: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.005
|
||||
- _QueueOffset: 0
|
||||
- _ReceiveShadows: 1
|
||||
- _Smoothness: 0.5
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _Surface: 0
|
||||
- _WorkflowMode: 1
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _BaseColor: {r: 0, g: 0, b: 1, a: 1}
|
||||
- _Color: {r: 0, g: 0, b: 1, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
|
||||
m_BuildTextureStacks: []
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 19bb1aa084d3a2c44aeb2f85fe619887
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f245e35bc6812714daa96301797a61ce
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 156aed9dc474aca42be120d5129fdba2
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8a23579ccee4cda48980583d99f8e07d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,90 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using static InterfaceManager;
|
||||
using System;
|
||||
|
||||
public class InterfaceTest : MonoBehaviour
|
||||
{
|
||||
public string url;
|
||||
public string[] query;
|
||||
public string[] query_value;
|
||||
|
||||
public string post_json;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
//Debug.Log("{\n \"base_url\": \"https://10.7.6.50:8080\",\n \"battery\": 0,\n \"current_mapname\": \"/home/cruiser/ros_ws/install/share/cruiser_navigation/maps/CWDT010@20231122_111258\",\n \"current_pose\": {\n \"id\": \"e5691290-8b71-48db-991d-c6b503def8b4\",\n \"theta\": 1.7360243797302246,\n \"x\": 5.016031742095947,\n \"y\": -2.2412776947021484\n },\n \"mode\": \"navigation\",\n \"name\": null,\n \"robotId\": \"56ce6c39b8144d91ac3767e757933955\",\n \"status\": null,\n \"system_status\": \"Healthy;\",\n \"system_status_code\": 0\n}");
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetKeyUp(KeyCode.G))
|
||||
{
|
||||
//²âÊÔ
|
||||
//if (query != null && query_value != null)
|
||||
//{
|
||||
// var dic = new Dictionary<string, string>();
|
||||
// for (int i = 0; i < query.Length; i++)
|
||||
// {
|
||||
// if (query_value.Length > i)
|
||||
// {
|
||||
// dic.Add(query[i], query_value[i]);
|
||||
// }
|
||||
// }
|
||||
// StartCoroutine(GetRequest(url, null, dic, (_data) =>
|
||||
// {
|
||||
// Debug.Log(_data);
|
||||
// }));
|
||||
//}
|
||||
|
||||
if (query != null && query_value != null)
|
||||
{
|
||||
var dic = new Dictionary<string, string>();
|
||||
for (int i = 0; i < query.Length; i++)
|
||||
{
|
||||
if (query_value.Length > i)
|
||||
{
|
||||
dic.Add(query[i], query_value[i]);
|
||||
}
|
||||
}
|
||||
StartCoroutine(GetRequest(url, new Dictionary<string, string>() { { "Authorization", "none" } }, dic, (_error, _data) =>
|
||||
{
|
||||
Debug.Log(_data);
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (Input.GetKeyUp(KeyCode.P))
|
||||
{
|
||||
StartCoroutine(PostRequest(url, post_json, new Dictionary<string, string>() { { "Authorization", "none" } }, (_error, _data) =>
|
||||
{
|
||||
Debug.Log(_data);
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
if (Input.GetKeyUp(KeyCode.Q))
|
||||
{
|
||||
Tex();
|
||||
}
|
||||
}
|
||||
|
||||
public string _data;
|
||||
public UnityEngine.UI.Image image;
|
||||
public void Tex()
|
||||
{
|
||||
byte[] bytes = Convert.FromBase64String(_data);
|
||||
Texture2D text2D = new Texture2D(100, 100);
|
||||
text2D.LoadImage(bytes);
|
||||
Sprite sprite = Sprite.Create(text2D, new Rect(0, 0, text2D.width, text2D.height), new Vector2(0.5f, 0.5f));
|
||||
//_callback?.Invoke(null, sprite);
|
||||
image.sprite = sprite;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 46320192a3399f14697958a6325ecb2a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,636 @@
|
|||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using System.Net.WebSockets;
|
||||
using static InterfaceManager;
|
||||
using System.Threading;
|
||||
using System;
|
||||
using System.Text;
|
||||
using Unity.VisualScripting;
|
||||
|
||||
public class RobotDataManager : MonoBehaviour
|
||||
{
|
||||
[Header("响应成功码")]
|
||||
public string rtCode = "0";
|
||||
|
||||
#region 初始化属性
|
||||
/// <summary>
|
||||
/// 是否初始化数据
|
||||
/// </summary>
|
||||
private bool init_data;
|
||||
/// <summary>
|
||||
/// 是否已获取【机器人列表】
|
||||
/// </summary>
|
||||
private bool get_robot_list_done;
|
||||
/// <summary>
|
||||
/// 是否已获取【机柜列表】
|
||||
/// </summary>
|
||||
private bool get_catrbin_list_done;
|
||||
/// <summary>
|
||||
/// 是否已获取【机器人地图数据】
|
||||
/// </summary>
|
||||
private bool get_robot_map_done;
|
||||
/// <summary>
|
||||
/// 是否已获取【定点任务-巡检点列表获取】、【机器人地图数据】
|
||||
/// </summary>
|
||||
private bool get_data_after_init_robot;
|
||||
/// <summary>
|
||||
/// 机器人信息接收次数
|
||||
/// </summary>
|
||||
private int get_info_times = 0;
|
||||
#endregion
|
||||
|
||||
#region 初始化数据
|
||||
|
||||
/// <summary>
|
||||
/// 【机器人列表】数据集合
|
||||
/// </summary>
|
||||
public List<RobotClass> RobotList = new List<RobotClass>();
|
||||
/// <summary>
|
||||
/// 【机柜列表】数据集合
|
||||
/// </summary>
|
||||
public List<CabinClass> CarbinList = new List<CabinClass>();
|
||||
/// <summary>
|
||||
/// 【定点任务-巡检点列表】数据集合
|
||||
/// </summary>
|
||||
public List<RobotFixedPointins> RobotFixedPointsins = new List<RobotFixedPointins>();
|
||||
/// <summary>
|
||||
/// 【机器人地图】数据
|
||||
/// </summary>
|
||||
public RobotMap RobotMap = new RobotMap();
|
||||
/// <summary>
|
||||
/// 【机器人任务队列】数据
|
||||
/// </summary>
|
||||
public RobotTask RobotTask = new RobotTask();
|
||||
/// <summary>
|
||||
/// 【巡检报表数据】
|
||||
/// </summary>
|
||||
public InsReport InsReport = new InsReport();
|
||||
|
||||
///// <summary>
|
||||
///// 【机器人位置状态信息】数据队列
|
||||
///// </summary>
|
||||
//public Queue<RobotPos> RobotPosQueue = new Queue<RobotPos>();
|
||||
/// <summary>
|
||||
/// 【机器人信息】
|
||||
/// </summary>
|
||||
public Queue<RobotInfo[]> RobotInfosQueue = new Queue<RobotInfo[]>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region 对象
|
||||
|
||||
/// <summary>
|
||||
/// 机器人对象
|
||||
/// </summary>
|
||||
public RobotObject RobotObject;
|
||||
|
||||
#endregion
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
///获取配置信息
|
||||
StartCoroutine(GetRequest(Path.Combine(Application.streamingAssetsPath, "robot.txt"), null, null, (_error, _json) =>
|
||||
{
|
||||
if (_error != null)
|
||||
{
|
||||
Debug.Log("请求【配置信息】错误:" + _error);
|
||||
return;
|
||||
}
|
||||
JObject _j = JObject.Parse(_json);
|
||||
http_ip_address = _j["http"].ToString();
|
||||
ws_ip_address = _j["ws"].ToString();
|
||||
http_ip_ma_address = _j["http_ma"].ToString();
|
||||
isLive = true;
|
||||
}));
|
||||
}
|
||||
|
||||
public string _pno;
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
Init();
|
||||
if (Input.GetKeyUp(KeyCode.Y))
|
||||
{
|
||||
//UsageExample(_pno);
|
||||
for (int i = 0; i < RobotFixedPointsins.Count; i++)
|
||||
{
|
||||
Debug.Log(RobotFixedPointsins[i].pointNo);
|
||||
}
|
||||
}
|
||||
if (Input.GetKeyUp(KeyCode.J))
|
||||
{
|
||||
UsageExample(_pno);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 需要Start中获取的数据在此执行
|
||||
/// 等待Start完成本地文件读取后执行
|
||||
/// </summary>
|
||||
public void Init()
|
||||
{
|
||||
if (!init_data && isLive)
|
||||
{
|
||||
init_data = true;
|
||||
Debug.Log("初始化数据");
|
||||
|
||||
//获取机器人列表
|
||||
StartCoroutine(GetRequest(http_ip_address + get_robot_list, request_header, null, (_error, _data) =>
|
||||
{
|
||||
if (_error != null)
|
||||
{
|
||||
Debug.Log("请求【机器人列表】错误:" + _error);
|
||||
return;
|
||||
}
|
||||
|
||||
var _response = JsonConvert.DeserializeObject<ResponseData>(_data);
|
||||
Debug.Log(_response.rtMsg);
|
||||
if (_response.rtCode.Equals(rtCode) && _response.rtData is JObject _jobject)
|
||||
{
|
||||
if (_jobject != null)
|
||||
{
|
||||
RobotList = _jobject["list"].ToObject<List<RobotClass>>();
|
||||
|
||||
//实例化实体机器人
|
||||
RobotObject.RobotClass = RobotList[0];
|
||||
}
|
||||
}
|
||||
get_robot_list_done = true;
|
||||
}));
|
||||
|
||||
//获取机柜列表
|
||||
StartCoroutine(GetRequest(http_ip_address + get_cabin_list, request_header, new Dictionary<string, string>() { { "isExport", "false" }, { "pageSize", "200" } }, (_error, _data) =>
|
||||
{
|
||||
if (_error != null)
|
||||
{
|
||||
Debug.Log("请求【机柜列表】错误:" + _error);
|
||||
return;
|
||||
}
|
||||
|
||||
var _response = JsonConvert.DeserializeObject<ResponseData>(_data);
|
||||
Debug.Log(_response.rtMsg);
|
||||
if (_response.rtCode.Equals(rtCode) && _response.rtData is JObject _jobject)
|
||||
{
|
||||
if (_jobject != null)
|
||||
{
|
||||
CarbinList = _jobject["list"].ToObject<List<CabinClass>>();
|
||||
}
|
||||
}
|
||||
get_catrbin_list_done = true;
|
||||
}));
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (get_robot_list_done && get_catrbin_list_done && !get_data_after_init_robot)
|
||||
{
|
||||
get_data_after_init_robot = true;
|
||||
|
||||
if (RobotList.Count < 1)
|
||||
{
|
||||
Debug.Log("机器人列表小于1!");
|
||||
return;
|
||||
}
|
||||
|
||||
//获取定点任务-巡检点列表
|
||||
StartCoroutine(GetRequest(http_ip_address + get_robot_fixed_pointins, request_header, new Dictionary<string, string>() { { "roomId", RobotList[0].roomId }, { "pageSize", "200" } }, (_error, _data) =>
|
||||
{
|
||||
if (_error != null)
|
||||
{
|
||||
Debug.Log("请求【定点任务-巡检点列表】错误:" + _error);
|
||||
return;
|
||||
}
|
||||
|
||||
var _response = JsonConvert.DeserializeObject<ResponseData>(_data);
|
||||
Debug.Log(_response.rtMsg);
|
||||
if (_response.rtCode.Equals(rtCode))
|
||||
{
|
||||
RobotFixedPointsins = JsonConvert.DeserializeObject<List<RobotFixedPointins>>(_response.rtData.ToString());
|
||||
}
|
||||
get_catrbin_list_done = true;
|
||||
}));
|
||||
|
||||
//获取机器人地图数据
|
||||
StartCoroutine(GetRequest(http_ip_address + get_robot_map + RobotObject.RobotClass.robot_id + "/map", request_header, new Dictionary<string, string>() { { "robotId", RobotList[0].robot_id } }, (_error, _data) =>
|
||||
{
|
||||
if (_error != null)
|
||||
{
|
||||
Debug.Log("请求【机器人地图数据】错误:" + _error);
|
||||
return;
|
||||
}
|
||||
|
||||
var _response = JsonConvert.DeserializeObject<ResponseData>(_data);
|
||||
Debug.Log(_response.rtMsg);
|
||||
if (_response.rtCode.Equals(rtCode) && _response.rtData is JObject _jobject)
|
||||
{
|
||||
if (_jobject != null)
|
||||
{
|
||||
RobotMap = _jobject.ToObject<RobotMap>();
|
||||
|
||||
//实例化实体机器人的地图数据
|
||||
RobotObject.RobotMap = RobotMap;
|
||||
}
|
||||
}
|
||||
get_robot_map_done = true;
|
||||
}));
|
||||
|
||||
//websocket
|
||||
WSRobotPos();
|
||||
//WSRobotInfo();
|
||||
}
|
||||
}
|
||||
|
||||
#region WebSocket数据接收
|
||||
|
||||
private ClientWebSocket ws_robot_pos;
|
||||
|
||||
/// <summary>
|
||||
/// 【机器人位置状态信息】
|
||||
/// </summary>
|
||||
private async void WSRobotPos()
|
||||
{
|
||||
try
|
||||
{
|
||||
ws_robot_pos = new ClientWebSocket();
|
||||
CancellationToken ct = new CancellationToken();
|
||||
var url = ws_ip_address + ws_robot_html5 + RobotObject.RobotClass.id;
|
||||
Debug.Log(url);
|
||||
Uri uri = new Uri(url);
|
||||
await ws_robot_pos.ConnectAsync(uri, ct);
|
||||
|
||||
while (true)
|
||||
{
|
||||
Debug.Log("111");
|
||||
var result = new byte[1024];
|
||||
await ws_robot_pos.ReceiveAsync(new ArraySegment<byte>(result), new CancellationToken());
|
||||
var str = Encoding.UTF8.GetString(result, 0, result.Length);
|
||||
//处理数据
|
||||
JObject _jobject = JObject.Parse(str);
|
||||
if (_jobject != null && _jobject["msg"] != null)
|
||||
{
|
||||
if (RobotObject != null)
|
||||
{
|
||||
RobotPos _robot_pos = JsonConvert.DeserializeObject<RobotPos>(_jobject["msg"].ToString());
|
||||
RobotObject.RobotPosQueue.Enqueue(_robot_pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError(ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 【机器人信息】
|
||||
/// </summary>
|
||||
private async void WSRobotInfo()
|
||||
{
|
||||
ClientWebSocket ws = new ClientWebSocket();
|
||||
CancellationToken ct = new CancellationToken();
|
||||
Uri uri = new Uri(ws_ip_address + ws_robot_info);
|
||||
await ws.ConnectAsync(uri, ct);
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (get_info_times == 0) continue;
|
||||
|
||||
var result = new byte[1024];
|
||||
await ws.ReceiveAsync(new ArraySegment<byte>(result), new CancellationToken());
|
||||
var str = Encoding.UTF8.GetString(result, 0, result.Length);
|
||||
//处理数据
|
||||
RobotInfo[] _robot_info = JsonConvert.DeserializeObject<RobotInfo[]>(str.ToString());
|
||||
RobotInfosQueue.Enqueue(_robot_info);
|
||||
|
||||
get_info_times++;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 功能点2:下发巡检任务
|
||||
|
||||
/*
|
||||
* 任务描述:
|
||||
* 功能:点击机柜,下发巡检任务。
|
||||
* 1.【获取机器人任务队列】先看机器人是否正在巡检(没有才下发)
|
||||
* 2.【定点任务下发】“pointList“参数中”pointNo “为机柜巡检点,其他参数照抄不动
|
||||
* 3.下发后看【获取机器人任务队列】是否巡检完成
|
||||
* 4.巡检完成查看【查询巡检报表数据】将“pic“字段的值从” thermal “开始拆分,把thermal后的截取出来,发送到后台进行保存。
|
||||
*/
|
||||
|
||||
/// <summary>
|
||||
/// 功能点2调用示例
|
||||
/// </summary>
|
||||
/// <param name="_point_no">点位编号</param>
|
||||
public void UsageExample(string _point_no)
|
||||
{
|
||||
//开始执行第一步:查询当前是否正在巡检
|
||||
GetTaskQueue((_error, _no_task) =>
|
||||
{
|
||||
if (_error != null)
|
||||
{
|
||||
Debug.Log(_error);
|
||||
return;
|
||||
}
|
||||
|
||||
//判断当前是否正在巡检
|
||||
if (!_no_task)
|
||||
{
|
||||
//如果准备下发巡检任务时正在巡检,则执行如下操作
|
||||
Debug.Log("当前正在巡检中!请稍后再试!");
|
||||
//ToDo
|
||||
//...
|
||||
//return;
|
||||
}
|
||||
|
||||
//若未在巡检,执行第二步:下发任务
|
||||
PostRobotTask(_point_no, (_error, _post_success) =>
|
||||
{
|
||||
//判断是否下发成功
|
||||
if (_error != null)
|
||||
{
|
||||
Debug.Log(_error);
|
||||
return;
|
||||
}
|
||||
//下发成功后开始执行第三步:循环查询直至结束任务
|
||||
StartCoroutine(Cyclic_GetTaskQuery((_error) =>
|
||||
{
|
||||
if (_error != null)
|
||||
{
|
||||
Debug.Log(_error);
|
||||
return;
|
||||
}
|
||||
|
||||
//任务结束后执行第四步:查看【查询巡检报表数据】将“pic“字段的值从” thermal “开始拆分,把thermal后的截取出来,发送到后台进行保存
|
||||
GetInsReport((_error, _success) =>
|
||||
{
|
||||
if (_error != null)
|
||||
{
|
||||
Debug.Log(_error);
|
||||
return;
|
||||
}
|
||||
|
||||
Dictionary<string, List<string>> _pics = new Dictionary<string, List<string>>();
|
||||
|
||||
for (int i = 0; i < InsReport.thermal.Count; i++)
|
||||
{
|
||||
var _ps = new List<string>();
|
||||
var pic1 = InsReport.thermal[i].pic1.Split("thermal")[1];
|
||||
var pic2 = InsReport.thermal[i].pic2.Split("thermal")[1];
|
||||
var pic3 = InsReport.thermal[i].pic3.Split("thermal")[1];
|
||||
var pic4 = InsReport.thermal[i].pic4.Split("thermal")[1];
|
||||
var pic5 = InsReport.thermal[i].pic5.Split("thermal")[1];
|
||||
var pic6 = InsReport.thermal[i].pic6.Split("thermal")[1];
|
||||
var pic7 = InsReport.thermal[i].pic7.Split("thermal")[1];
|
||||
|
||||
_ps.Add(pic1);
|
||||
_ps.Add(pic2);
|
||||
_ps.Add(pic3);
|
||||
_ps.Add(pic4);
|
||||
_ps.Add(pic5);
|
||||
_ps.Add(pic6);
|
||||
_ps.Add(pic7);
|
||||
|
||||
_pics.Add(InsReport.thermal[i].id, _ps);
|
||||
}
|
||||
//ToDo
|
||||
//将处理好的数据发送给后台
|
||||
//...
|
||||
Debug.Log("图片路径处理完成!");
|
||||
});
|
||||
}));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取机器人任务列队
|
||||
/// </summary>
|
||||
/// <param name="_callback">参数1:异常信息;参数2:true->当前未在巡检</param>
|
||||
public void GetTaskQueue(Action<string, bool> _callback = null)
|
||||
{
|
||||
Debug.Log("查询当前巡检状态中...");
|
||||
//注意接口地址中最后一个为机器人id,后期根据业务修改机器人id
|
||||
StartCoroutine(GetRequest(http_ip_address + get_task_queue + RobotObject.RobotClass.robot_id, request_header, null, (_error, _data) =>
|
||||
{
|
||||
if (_error != null)
|
||||
{
|
||||
_callback?.Invoke(_error, false);
|
||||
return;
|
||||
}
|
||||
|
||||
var _response = JsonConvert.DeserializeObject<ResponseData>(_data);
|
||||
if (_response.rtCode.Equals(rtCode) && _response.rtData is JObject _jobject)
|
||||
{
|
||||
Debug.Log(_response.rtMsg);
|
||||
if (_jobject != null)
|
||||
{
|
||||
RobotTask = _jobject.ToObject<RobotTask>();
|
||||
|
||||
//实例化实体机器人的任务数据,注意机器人id是否匹配
|
||||
RobotObject.RobotTask = RobotTask;
|
||||
|
||||
//判断每条 RobotTask.data[].Task_type是否为fixed
|
||||
//...如果没有返回True,表示未在巡检,否则返回False
|
||||
_callback?.Invoke(null, RobotTask.data == null || RobotTask.data.Count == 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_callback?.Invoke(_response.rtMsg, false);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 机器人任务下发
|
||||
/// </summary>
|
||||
public void PostRobotTask(string _point_no, Action<string, bool> _callback = null)
|
||||
{
|
||||
string _json_data = "{\r\n \"robotIp\": \"192.168.8.198\",\r\n \"pointList\": [\r\n {\r\n \"pointNo\": \"" + _point_no + "\",\r\n \"04\": \"0\",\r\n \"06\": \"0\",\r\n \"01\": \"1\",\r\n \"cabinType\": \"1\",\r\n \"03\": \"0\",\r\n \"05\": \"0\"\r\n }\r\n ]\r\n}";
|
||||
|
||||
StartCoroutine(PostRequest(http_ip_address + post_robot_fixed_point, _json_data, request_header, (_error, _data) =>
|
||||
{
|
||||
if (_error != null)
|
||||
{
|
||||
Debug.Log(_error);
|
||||
_callback?.Invoke(_error, false);
|
||||
return;
|
||||
}
|
||||
|
||||
var _response = JsonConvert.DeserializeObject<ResponseData>(_data);
|
||||
Debug.Log(_response.rtMsg);
|
||||
if (_response.rtCode.Equals(rtCode))//返回值匹配表示下发成功
|
||||
{
|
||||
//下发成功后循环执行获取机器人任务队列,直至任务队列为空后继续执行后续操作
|
||||
_callback?.Invoke(null, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
_callback?.Invoke(_response.rtMsg, false);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行循环查询等待操作
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IEnumerator Cyclic_GetTaskQuery(Action<string> _callback = null)
|
||||
{
|
||||
int _call_time = 0;//调用次数
|
||||
int _response_time = 0;//返回次数
|
||||
bool _finish = false;//结束循环操作
|
||||
int _error_time = 0;
|
||||
while (true)
|
||||
{
|
||||
if (_finish) break;
|
||||
|
||||
//循环查询异常次数超过一定值,结束查询并跳出循环,避免过多不必要的开销
|
||||
if (_error_time > 3)
|
||||
{
|
||||
_callback?.Invoke("查询异常!");
|
||||
break;
|
||||
}
|
||||
|
||||
yield return new WaitForSeconds(3);
|
||||
|
||||
if (_call_time != _response_time) continue;
|
||||
|
||||
#region 测试
|
||||
|
||||
if (_response_time == 3)
|
||||
{
|
||||
Debug.Log("测试:等待次数过多");
|
||||
_callback?.Invoke(null);
|
||||
break;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
_call_time++;
|
||||
Debug.Log("执行第" + _call_time + "次循环");
|
||||
GetTaskQueue((_error, _no_task) =>
|
||||
{
|
||||
if (_error != null)
|
||||
{
|
||||
_error_time++;
|
||||
_response_time++;
|
||||
Debug.Log("请求返回第" + _response_time + "次");
|
||||
return;
|
||||
}
|
||||
if (_no_task)
|
||||
{
|
||||
//当前无任务,结束循环操作
|
||||
_finish = true;
|
||||
_callback?.Invoke(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
//当前任务尚未结束,继续执行循环操作等待任务结束
|
||||
_response_time++;
|
||||
Debug.Log("请求返回第" + _response_time + "次");
|
||||
}
|
||||
});
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取巡检报表数据
|
||||
/// </summary>
|
||||
public void GetInsReport(Action<string, bool> _callback)
|
||||
{
|
||||
//需补充请求参数,机器人任务队列中的Ins_Id,根据业务筛选具体数据
|
||||
StartCoroutine(GetRequest(http_ip_address + get_record_ins_report, request_header, new Dictionary<string, string>() { { "insId", RobotTask.data[0].Ins_Id } }, (_error, _data) =>
|
||||
{
|
||||
if (_error != null)
|
||||
{
|
||||
Debug.Log(_error);
|
||||
_callback?.Invoke(_error, false);
|
||||
return;
|
||||
}
|
||||
|
||||
var _response = JsonConvert.DeserializeObject<ResponseData>(_data);
|
||||
if (_response.rtCode.Equals(rtCode) && _response.rtData is JObject _jobject)
|
||||
{
|
||||
Debug.Log(_response.rtMsg);
|
||||
if (_jobject != null)
|
||||
{
|
||||
InsReport = _jobject.ToObject<InsReport>();
|
||||
|
||||
_callback?.Invoke(null, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_callback?.Invoke(_response.rtMsg, false);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 功能点3:巡检结果查看
|
||||
|
||||
public void ViewInspectionResults(Action<string, List<Sprite>> _callback)
|
||||
{
|
||||
//注意补充Token值
|
||||
StartCoroutine(GetRequest(http_ip_ma_address + get_inspection, new Dictionary<string, string>() { { "X-Token", "" } }, null, (_error, _data) =>
|
||||
{
|
||||
if (_error != null)
|
||||
{
|
||||
Debug.Log(_error);
|
||||
_callback?.Invoke(_error, null);
|
||||
return;
|
||||
}
|
||||
|
||||
ResponseData_ma response = JsonConvert.DeserializeObject<ResponseData_ma>(_data);
|
||||
if (response.message.Equals("操作成功") && response.data is JObject jobject)
|
||||
{
|
||||
if (response.data != null)
|
||||
{
|
||||
var inspection_datas = jobject.ToObject<List<InspectionResult>>();
|
||||
|
||||
var sprites = new List<Sprite>();
|
||||
for (int i = 0; i < inspection_datas.Count; i++)
|
||||
{
|
||||
//base64转图片
|
||||
byte[] bytes = Convert.FromBase64String(_data);
|
||||
Texture2D text2D = new Texture2D(100, 100);
|
||||
text2D.LoadImage(bytes);
|
||||
Sprite sprite = Sprite.Create(text2D, new Rect(0, 0, text2D.width, text2D.height), new Vector2(0.5f, 0.5f));
|
||||
sprites.Add(sprite);
|
||||
}
|
||||
_callback?.Invoke(null, sprites);
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
CloseClientWebSocket();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭ClientWebSocket。
|
||||
/// </summary>
|
||||
public void CloseClientWebSocket()
|
||||
{
|
||||
//关闭Socket
|
||||
if (ws_robot_pos != null && ws_robot_pos.State == WebSocketState.Open)
|
||||
{
|
||||
var task = ws_robot_pos.CloseAsync(WebSocketCloseStatus.NormalClosure, string.Empty, CancellationToken.None);
|
||||
task.Wait();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ba1987dfd90a1ed48a09c0e1bff9ab1a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,18 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class RobotMapCreater : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6e1b4822f6974f843a826d8df9bc7d96
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,95 @@
|
|||
using BestHTTP.SecureProtocol.Org.BouncyCastle.Tsp;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using DG.Tweening;
|
||||
using UnityEngine.UI;
|
||||
|
||||
/// <summary>
|
||||
/// 机器人对象
|
||||
/// </summary>
|
||||
public class RobotObject : MonoBehaviour
|
||||
{
|
||||
public RectTransform rect_transform;
|
||||
/*
|
||||
bmp_x = origin.x
|
||||
*/
|
||||
/// <summary>
|
||||
/// 机器人信息
|
||||
/// </summary>
|
||||
public RobotClass RobotClass = null;
|
||||
/// <summary>
|
||||
/// 机器人地图数据
|
||||
/// </summary>
|
||||
public RobotMap RobotMap = null;
|
||||
/// <summary>
|
||||
/// 机器人位置状态信息
|
||||
/// </summary>
|
||||
public Queue<RobotPos> RobotPosQueue = new Queue<RobotPos>();
|
||||
/// <summary>
|
||||
/// 机器人任务队列
|
||||
/// </summary>
|
||||
public RobotTask RobotTask = null;
|
||||
|
||||
/// <summary>
|
||||
/// 当前执行的机器人位置信息
|
||||
/// </summary>
|
||||
private RobotPos current_robot_pos = null;
|
||||
|
||||
//固定值
|
||||
public int origin_x;//=info.origin.x
|
||||
public int origin_y;//=info.origin.y
|
||||
public int pixel_width;//info.width
|
||||
public int pixel_height;//info.height
|
||||
public double resolution;//=info.resolution
|
||||
//public double bmp_x;//=origin.x/resolution
|
||||
//public double bmp_y;//=info.height-(origin.y/resolution)
|
||||
//public float bmp_h;//=info.height
|
||||
//public float bmp_w;//=info.width
|
||||
|
||||
//实时值
|
||||
//public double map_x;//=current_pos.x
|
||||
//public double map_y;//=current_pos.y
|
||||
public double display_x;//=(current_pos.x-origin.x)/resolution
|
||||
public double display_y;//=(current_pos.y-origin.y)/resolution
|
||||
|
||||
private bool get;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
rect_transform = GetComponent<RectTransform>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (RobotClass == null || RobotMap == null) return;
|
||||
if (!get)
|
||||
{
|
||||
get = true;
|
||||
origin_x = RobotMap.info.origin.x;
|
||||
origin_y = RobotMap.info.origin.y;
|
||||
pixel_width = RobotMap.info.width;
|
||||
pixel_height = RobotMap.info.height;
|
||||
resolution = RobotMap.info.resolution;
|
||||
}
|
||||
|
||||
if (RobotPosQueue.Count > 0 && current_robot_pos == null)
|
||||
{
|
||||
current_robot_pos = RobotPosQueue.Peek();
|
||||
//Debug.Log(Newtonsoft.Json.JsonConvert.SerializeObject(current_robot_pos));
|
||||
|
||||
display_x = (current_robot_pos.current_pose.x - origin_x) / resolution;
|
||||
display_y = (current_robot_pos.current_pose.x - origin_y) / resolution;
|
||||
|
||||
display_x *= (rect_transform.sizeDelta.x / pixel_width);
|
||||
display_y *= (rect_transform.sizeDelta.y / pixel_height);
|
||||
|
||||
rect_transform.DOAnchorPos(new Vector2((float)display_x, (float)display_y), 0.5f).OnComplete(() =>
|
||||
{
|
||||
RobotPosQueue.Dequeue();
|
||||
current_robot_pos = null;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 204b2add5d8a2794fa97ca8d1756f6ab
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c2b807ba48e50a44aa3ec0c213d3f0cd
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 150239179b5713241b84cb14da8f8fa8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,273 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
|
||||
public static class InterfaceManager
|
||||
{
|
||||
#region 接口地址
|
||||
|
||||
/// <summary>
|
||||
/// 是否可用
|
||||
/// </summary>
|
||||
public static bool isLive = false;
|
||||
|
||||
/// <summary>
|
||||
/// http接口ip地址
|
||||
/// </summary>
|
||||
public static string http_ip_address { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ws服务地址
|
||||
/// </summary>
|
||||
public static string ws_ip_address { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 马允波提供的后台ip,
|
||||
/// </summary>
|
||||
public static string http_ip_ma_address { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 请求头
|
||||
/// </summary>
|
||||
public static Dictionary<string, string> request_header = new Dictionary<string, string>() { { "Authorization", "none" } };
|
||||
|
||||
/// <summary>
|
||||
/// 机房列表
|
||||
/// 参数:
|
||||
/// isExport=false¤tPage=1&pageSize=10
|
||||
/// </summary>
|
||||
public static string get_room_list => "/jk/room/list";
|
||||
|
||||
/// <summary>
|
||||
/// 巡检数据
|
||||
/// 参数:
|
||||
/// pageSize=1¤tPage=0&isExport=false
|
||||
/// </summary>
|
||||
public static string get_record_list => "/jk/record/list";
|
||||
|
||||
/// <summary>
|
||||
/// 机器人列表
|
||||
/// </summary>
|
||||
public static string get_robot_list => "/jk/robot/list";
|
||||
|
||||
/// <summary>
|
||||
/// 设备列表
|
||||
/// 参数:
|
||||
/// isExport=false
|
||||
/// </summary>
|
||||
public static string get_device_list => "/jk/device/list";
|
||||
|
||||
/// <summary>
|
||||
/// 机柜列表
|
||||
/// 参数:
|
||||
/// isExport=false
|
||||
/// pageSize=200
|
||||
/// </summary>
|
||||
public static string get_cabin_list => "/jk/cabin/list";
|
||||
|
||||
/// <summary>
|
||||
/// 机器人摄像头信息
|
||||
/// 参数:
|
||||
/// robotId=56ce6c39b8144d91ac3767e757933955
|
||||
/// </summary>
|
||||
public static string get_robot_camera_rtsp => "/jk/robotParam/getCameraRtspParams";
|
||||
|
||||
/// <summary>
|
||||
/// 机器人地图
|
||||
/// 注意接口参数:/robot/{robotId}/map
|
||||
/// 参数:
|
||||
/// robotId=56ce6c39b8144d91ac3767e757933955
|
||||
/// </summary>
|
||||
public static string get_robot_map => "/jk/robot/";
|
||||
|
||||
/// <summary>
|
||||
/// 任务列表查询
|
||||
/// </summary>
|
||||
public static string get_task_list => "/jk/task/list";
|
||||
|
||||
/// <summary>
|
||||
/// 任务详情
|
||||
/// </summary>
|
||||
public static string get_task => "/jk/task/2fc8b609e202404db573946da7e30b57";
|
||||
|
||||
/// <summary>
|
||||
/// 机器人任务队列
|
||||
///
|
||||
/// </summary>
|
||||
public static string get_task_queue => "/jk/task/taskqueue/list/";
|
||||
|
||||
/// <summary>
|
||||
/// 定点任务下发
|
||||
/// 参数:
|
||||
/// { "robotIp": "192.168.8.198", "pointList": [ { "pointNo": "xj01", "04": "0", "06": "0", "01": "1", "cabinType": "1", "03": "0", "05": "0" } ]}
|
||||
/// </summary>
|
||||
public static string post_robot_fixed_point => "/jk/robot/dofixedPointins";
|
||||
|
||||
/// <summary>
|
||||
/// 立即执行任务队列中的任务
|
||||
/// 参数:
|
||||
/// { "robotId": "3e42c3014eb5463a94602c13dfc0921c", "TaskQueue_Id": "1686128400786", "interfaceNo": "goToQueueTask"}
|
||||
/// </summary>
|
||||
public static string post_robot_send_commond => "/jk/interface/sendCommand";
|
||||
|
||||
/// <summary>
|
||||
/// 定点任务-巡检点列表查询接口
|
||||
/// 参数:
|
||||
/// roomId=0703de6c8f6111eeb00f0242ac0a0005
|
||||
/// </summary>
|
||||
public static string get_robot_fixed_pointins => "/jk/robot/fixedPointins";
|
||||
|
||||
/// <summary>
|
||||
/// 巡检任务下发
|
||||
/// 参数:
|
||||
/// { "taskId": "", "robotId": "56ce6c39b8144d91ac3767e757933955", "robotIp": "192.168.8.198"}
|
||||
/// </summary>
|
||||
public static string post_robot_doins_task => "/jk/robot/doinsTask";
|
||||
|
||||
/// <summary>
|
||||
/// 巡检任务-任务列表查询接口
|
||||
/// 参数:
|
||||
/// roomId=0703de6c8f6111eeb00f0242ac0a0005
|
||||
/// </summary>
|
||||
public static string get_robot_ins_task => "/jk/robot/insTask";
|
||||
|
||||
/// <summary>
|
||||
/// 查询巡检报表数据
|
||||
/// 参数:
|
||||
/// insId=6978d1982a4449c48f7e4b2064d1b28b
|
||||
/// </summary>
|
||||
public static string get_record_ins_report => "/jk/record/insReport";
|
||||
|
||||
/// <summary>
|
||||
/// 巡检数据告警详情
|
||||
/// 参数:
|
||||
/// isExport=false
|
||||
/// rocerdId=1f77ddf75f9f490ba84fb2a125962903
|
||||
/// </summary>
|
||||
public static string get_record_task_list => "/jk/record/tasklist";
|
||||
|
||||
/// <summary>
|
||||
/// 巡检数据停检位置告警列表
|
||||
/// 参数:
|
||||
/// inspectionPointId=1f77ddf75f9f490ba84fb2a125962903
|
||||
/// </summary>
|
||||
public static string get_record_dev_list => "/jk/record/devList";
|
||||
|
||||
/// <summary>
|
||||
/// 巡检数据停检位置巡检图片
|
||||
/// 参数:
|
||||
/// inspectionPointId=1f77ddf75f9f490ba84fb2a125962903
|
||||
/// </summary>
|
||||
public static string get_record_pic => "/jk/record/getPic";
|
||||
|
||||
/// <summary>
|
||||
/// 获取机器人信息
|
||||
/// </summary>
|
||||
public static string ws_robot_info => "/jk/api/robotinfo/clkc5gnu5000d3p6p8lu41tnj-clkc5gnu5000e3p6pvux9aid3-socket_index_page_robot_info";
|
||||
|
||||
/// <summary>
|
||||
/// 机器人位置状态信息
|
||||
/// 参数:
|
||||
/// 机器人id,直接拼接在地址后面
|
||||
/// </summary>
|
||||
public static string ws_robot_html5 => "/jk/api/html5/";
|
||||
|
||||
/// <summary>
|
||||
/// 巡检结果
|
||||
/// </summary>
|
||||
public static string get_inspection => "/robot/queryInspection";
|
||||
|
||||
#endregion
|
||||
|
||||
#region 调接口
|
||||
|
||||
/// <summary>
|
||||
/// Get请求
|
||||
/// </summary>
|
||||
/// <param name="_url"></param>
|
||||
/// <param name="_header"></param>
|
||||
/// <param name="_query"></param>
|
||||
/// <param name="_callback"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerator GetRequest(string _url, Dictionary<string, string> _header = null, Dictionary<string, string> _query = null, Action<string, string> _callback = null)
|
||||
{
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.Append(_url);
|
||||
|
||||
if (_query != null)
|
||||
{
|
||||
builder.Append("?");
|
||||
int i = 0;
|
||||
foreach (var item in _query)
|
||||
{
|
||||
if (i > 0)
|
||||
builder.Append("&");
|
||||
builder.AppendFormat("{0}={1}", item.Key, item.Value);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
using (UnityWebRequest request = UnityWebRequest.Get(builder.ToString()))
|
||||
{
|
||||
if (_header != null)
|
||||
{
|
||||
foreach (var item in _header)
|
||||
{
|
||||
request.SetRequestHeader(item.Key, item.Value);
|
||||
}
|
||||
}
|
||||
|
||||
yield return request.SendWebRequest();
|
||||
|
||||
if (request.error != null)
|
||||
{
|
||||
_callback?.Invoke(request.error, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
_callback?.Invoke(null, request.downloadHandler.text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Post请求
|
||||
/// </summary>
|
||||
/// <param name="_url"></param>
|
||||
/// <param name="_post_json"></param>
|
||||
/// <param name="_callback"></param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerator PostRequest(string _url, string _post_json, Dictionary<string, string> _header = null, Action<string, string> _callback = null)
|
||||
{
|
||||
using (UnityWebRequest request = new UnityWebRequest(_url, "POST"))
|
||||
{
|
||||
var data = Encoding.UTF8.GetBytes(_post_json);
|
||||
request.uploadHandler = new UploadHandlerRaw(data);
|
||||
request.downloadHandler = new DownloadHandlerBuffer();
|
||||
|
||||
if (_header != null)
|
||||
{
|
||||
foreach (var item in _header)
|
||||
{
|
||||
request.SetRequestHeader(item.Key, item.Value);
|
||||
}
|
||||
}
|
||||
|
||||
yield return request.SendWebRequest();
|
||||
if (request.error != null)
|
||||
{
|
||||
_callback?.Invoke(request.error, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
_callback?.Invoke(null, request.downloadHandler.text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fd68e83d441514845924ab921fd17b5d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"http":"http://192.168.8.11:8000",
|
||||
"ws":"ws://192.168.8.11:8000",
|
||||
"http_ma":"http://192.168.8.11:8081"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d0d0e688921029c41990e42fdb1ab73b
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in New Issue