You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
2.4 KiB
75 lines
2.4 KiB
using Model;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace CommonHelper
|
|
{
|
|
/// <summary>
|
|
/// AGV相关帮助类
|
|
/// 作者:ld
|
|
/// 日期:2023-04-11
|
|
/// </summary>
|
|
public static class AGVHelper
|
|
{
|
|
#region 获取token
|
|
/// <summary>
|
|
/// 获取token
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static string GetToken(string username, string password)
|
|
{
|
|
string resultData = string.Empty;
|
|
string postUrl = @"http://ip:port/pord-api/api/login";
|
|
RequestTokenModel requestTokenModel = new RequestTokenModel()
|
|
{
|
|
username = username,
|
|
password = password
|
|
};
|
|
string requestTokenJson = JsonConvert.SerializeObject(requestTokenModel);
|
|
HttpHelper.PostData(postUrl, requestTokenJson, ref resultData);
|
|
return resultData;
|
|
}
|
|
#endregion
|
|
|
|
#region 操作AGV
|
|
/// <summary>
|
|
/// 操作AGV
|
|
/// </summary>
|
|
/// <param name="requestModel">AGV请求参数</param>
|
|
/// <returns></returns>
|
|
public static AGVResponseModel OperateAGV(AGVRequestModel requestModel)
|
|
{
|
|
AGVResponseModel responseModel;
|
|
try
|
|
{
|
|
string resultData = string.Empty;
|
|
string postUrl = @"http://ip:port/pord-api/v1/movePallet";
|
|
string requestStr = JsonConvert.SerializeObject(requestModel);
|
|
Dictionary<string, string> header = new Dictionary<string, string>();
|
|
header.Add("token", "token值");
|
|
bool result = HttpHelper.PostData(postUrl, requestStr, header, ref resultData);
|
|
if (result)
|
|
{
|
|
responseModel = JsonConvert.DeserializeObject<AGVResponseModel>(resultData);
|
|
}
|
|
else
|
|
{
|
|
responseModel = new AGVResponseModel();
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
responseModel = new AGVResponseModel();
|
|
}
|
|
if (responseModel == null)
|
|
{
|
|
responseModel = new AGVResponseModel();
|
|
}
|
|
return responseModel;
|
|
}
|
|
#endregion
|
|
}
|
|
}
|