Commit 1a7b2329 张东亮

1

1 个父辈 959d8cdd
...@@ -5,10 +5,12 @@ using OnlineStore; ...@@ -5,10 +5,12 @@ using OnlineStore;
using OnlineStore.Common; using OnlineStore.Common;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms;
using static DL.StandardRobot.StandardRobot; using static DL.StandardRobot.StandardRobot;
namespace DeviceLibrary namespace DeviceLibrary
...@@ -105,7 +107,15 @@ namespace DeviceLibrary ...@@ -105,7 +107,15 @@ namespace DeviceLibrary
} }
} }
} }
/// <summary>
/// 入料口
/// </summary>
const string B1 = "B1";
/// <summary>
/// 出料口
/// </summary>
const string B2 = "B2";
const string MIMO = "MIMO";
/// <summary> /// <summary>
/// 处理AGV请求的操作 /// 处理AGV请求的操作
/// </summary> /// </summary>
...@@ -114,15 +124,23 @@ namespace DeviceLibrary ...@@ -114,15 +124,23 @@ namespace DeviceLibrary
public static void HandleDeviceOperate(DeviceCheckDto deviceCheckDto, out RtnData rtnData) public static void HandleDeviceOperate(DeviceCheckDto deviceCheckDto, out RtnData rtnData)
{ {
rtnData = new RtnData(); rtnData = new RtnData();
if (deviceCheckDto.device_code.Equals(B1) || deviceCheckDto.device_code.Equals(B2))
switch (deviceCheckDto.task_type)
{ {
case STDTaskType.NS200_LOAD_B1://NS200入料口上料任务 if (!RobotManage.isRunning)
{
rtnData.code = 201;
rtnData.msg = crc.GetString("Res0079", "机器尚未启动不能呼叫Agv");
return;
}
}
switch (deviceCheckDto.device_code)
{
case B1://NS200入料口上料任务
if (DeviceCheckDto.LOAD_REQ.Equals(deviceCheckDto.operate))//上料请求 if (DeviceCheckDto.LOAD_REQ.Equals(deviceCheckDto.operate))//上料请求
{ {
if (!RobotManage.isRunning) if (!RobotManage.isRunning)
{ {
rtnData.code = -1; rtnData.code = 201;
rtnData.msg = crc.GetString("Res0079", "机器尚未启动不能呼叫Agv"); rtnData.msg = crc.GetString("Res0079", "机器尚未启动不能呼叫Agv");
} }
else else
...@@ -134,22 +152,15 @@ namespace DeviceLibrary ...@@ -134,22 +152,15 @@ namespace DeviceLibrary
{ {
if (RobotManage.mainMachine.RightMoveInfo.MoveStep >= MoveStep.R40_InShelf) if (RobotManage.mainMachine.RightMoveInfo.MoveStep >= MoveStep.R40_InShelf)
{ {
rtnData.code = -1; rtnData.code = 201;
rtnData.msg = "入料口正在进料"; rtnData.msg = "入料口正在进料";
} }
} }
else else if (DeviceCheckDto.UNLOAD_REQ.Equals(deviceCheckDto.operate))//下料请求
{
rtnData.code = -1;
rtnData.msg = "任务类型" + deviceCheckDto.task_type + "不允许使用该操作" + deviceCheckDto.operate;
}
break;
case STDTaskType.NS200_UNLOAD_B1://NS200入料口下料任务
if (DeviceCheckDto.UNLOAD_REQ.Equals(deviceCheckDto.operate))//下料请求
{ {
if (!RobotManage.isRunning) if (!RobotManage.isRunning)
{ {
rtnData.code = -1; rtnData.code = 201;
rtnData.msg = crc.GetString("Res0079", "机器尚未启动不能呼叫Agv"); rtnData.msg = crc.GetString("Res0079", "机器尚未启动不能呼叫Agv");
} }
else else
...@@ -161,22 +172,22 @@ namespace DeviceLibrary ...@@ -161,22 +172,22 @@ namespace DeviceLibrary
{ {
if (RobotManage.mainMachine.RightMoveInfo.MoveStep >= MoveStep.R30_OutShelf) if (RobotManage.mainMachine.RightMoveInfo.MoveStep >= MoveStep.R30_OutShelf)
{ {
rtnData.code = -1; rtnData.code = 201;
rtnData.msg = "入料口正在出料"; rtnData.msg = "入料口正在出料";
} }
} }
else else
{ {
rtnData.code = -1; rtnData.code = 201;
rtnData.msg = "任务类型" + deviceCheckDto.task_type + "不允许使用该操作" + deviceCheckDto.operate; rtnData.msg = "任务类型" + deviceCheckDto.task_type + "不允许使用该操作" + deviceCheckDto.operate;
} }
break; break;
case STDTaskType.NS200_LOAD_B2://NS200出料口上料任务 case B2://NS200出料口上料任务
if (DeviceCheckDto.LOAD_REQ.Equals(deviceCheckDto.operate))//上料请求 if (DeviceCheckDto.LOAD_REQ.Equals(deviceCheckDto.operate))//上料请求
{ {
if (!RobotManage.isRunning) if (!RobotManage.isRunning)
{ {
rtnData.code = -1; rtnData.code = 201;
rtnData.msg = crc.GetString("Res0079", "机器尚未启动不能呼叫Agv"); rtnData.msg = crc.GetString("Res0079", "机器尚未启动不能呼叫Agv");
} }
else else
...@@ -188,22 +199,15 @@ namespace DeviceLibrary ...@@ -188,22 +199,15 @@ namespace DeviceLibrary
{ {
if (RobotManage.mainMachine.LeftMoveInfo.MoveStep >= MoveStep.L60_InShelf) if (RobotManage.mainMachine.LeftMoveInfo.MoveStep >= MoveStep.L60_InShelf)
{ {
rtnData.code = -1; rtnData.code = 201;
rtnData.msg = "出料口正在入料"; rtnData.msg = "出料口正在入料";
} }
} }
else else if (DeviceCheckDto.UNLOAD_REQ.Equals(deviceCheckDto.operate))//下料请求
{
rtnData.code = -1;
rtnData.msg = "任务类型" + deviceCheckDto.task_type + "不允许使用该操作" + deviceCheckDto.operate;
}
break;
case STDTaskType.NS200_UNLOAD_B2://NS200出料口下料任务
if (DeviceCheckDto.UNLOAD_REQ.Equals(deviceCheckDto.operate))//下料请求
{ {
if (!RobotManage.isRunning) if (!RobotManage.isRunning)
{ {
rtnData.code = -1; rtnData.code = 201;
rtnData.msg = crc.GetString("Res0079", "机器尚未启动不能呼叫Agv"); rtnData.msg = crc.GetString("Res0079", "机器尚未启动不能呼叫Agv");
} }
else else
...@@ -215,22 +219,22 @@ namespace DeviceLibrary ...@@ -215,22 +219,22 @@ namespace DeviceLibrary
{ {
if (RobotManage.mainMachine.LeftMoveInfo.MoveStep >= MoveStep.L50_OutShelf) if (RobotManage.mainMachine.LeftMoveInfo.MoveStep >= MoveStep.L50_OutShelf)
{ {
rtnData.code = -1; rtnData.code = 201;
rtnData.msg = "出料口正在出料"; rtnData.msg = "出料口正在出料";
} }
} }
else else
{ {
rtnData.code = -1; rtnData.code = 201;
rtnData.msg = "任务类型" + deviceCheckDto.task_type + "不允许使用该操作" + deviceCheckDto.operate; rtnData.msg = "任务类型" + deviceCheckDto.task_type + "不允许使用该操作" + deviceCheckDto.operate;
} }
break; break;
case STDTaskType.MIMO_LOAD://MIMO上料任务 case MIMO://MIMO上料任务
if (DeviceCheckDto.LOAD_REQ.Equals(deviceCheckDto.operate))//上料请求 if (DeviceCheckDto.LOAD_REQ.Equals(deviceCheckDto.operate))//上料请求
{ {
if (!StringDoorIsOpen) if (!StringDoorIsOpen)
{ {
rtnData.code = -1; rtnData.code = 201;
rtnData.msg = "折叠门开门信号未亮,不允许上料"; rtnData.msg = "折叠门开门信号未亮,不允许上料";
} }
else else
...@@ -254,19 +258,11 @@ namespace DeviceLibrary ...@@ -254,19 +258,11 @@ namespace DeviceLibrary
{ {
} }
else else if (DeviceCheckDto.UNLOAD_REQ.Equals(deviceCheckDto.operate))//下料请求
{
rtnData.code = -1;
rtnData.msg = "任务类型" + deviceCheckDto.task_type + "不允许使用该操作" + deviceCheckDto.operate;
}
break;
case STDTaskType.MIMO_UNLOAD:////MIMO下料任务
if (DeviceCheckDto.UNLOAD_REQ.Equals(deviceCheckDto.operate))//下料请求
{ {
if (!StringDoorIsOpen) if (!StringDoorIsOpen)
{ {
rtnData.code = -1; rtnData.code = 201;
rtnData.msg = "折叠门开门信号未亮,不允许下料"; rtnData.msg = "折叠门开门信号未亮,不允许下料";
} }
else else
...@@ -292,12 +288,13 @@ namespace DeviceLibrary ...@@ -292,12 +288,13 @@ namespace DeviceLibrary
} }
else else
{ {
rtnData.code = -1; rtnData.code = 201;
rtnData.msg = "任务类型" + deviceCheckDto.task_type + "不允许使用该操作" + deviceCheckDto.operate; rtnData.msg = "任务类型" + deviceCheckDto.task_type + "不允许使用该操作" + deviceCheckDto.operate;
} }
break; break;
} }
sendAgvLog($"AGV在设备{deviceCheckDto.device_code}的操作{deviceCheckDto.operate}"); if (rtnData.code == 200)
sendAgvLog($"收到AGV对设备{deviceCheckDto.device_code}的操作{deviceCheckDto.operate}请求");
} }
static Dictionary<string, string> StringDoor(bool open) static Dictionary<string, string> StringDoor(bool open)
{ {
...@@ -384,8 +381,17 @@ namespace DeviceLibrary ...@@ -384,8 +381,17 @@ namespace DeviceLibrary
RtnData rtnData = JsonHelper.DeserializeJsonToObject<RtnData>(result); RtnData rtnData = JsonHelper.DeserializeJsonToObject<RtnData>(result);
if (rtnData != null) if (rtnData != null)
{ {
if (rtnData.code == 0) if (rtnData.code == 200)
{ {
//出入料口操作
if (STDTaskType.NS200_UNLOAD_B1.Equals(task_type))
{
releaseRight();
}
else if (STDTaskType.NS200_UNLOAD_B2.Equals(task_type))
{
releaseLeft();
}
UpdateTaskStatus(taskDto.task_code, taskDto.task_type); UpdateTaskStatus(taskDto.task_code, taskDto.task_type);
return true; return true;
} }
...@@ -397,53 +403,119 @@ namespace DeviceLibrary ...@@ -397,53 +403,119 @@ namespace DeviceLibrary
} }
return false; return false;
} }
}
public class TaskDto
{
/// <summary>
/// 任务编码
/// </summary>
public string task_code { get; set; }
/// <summary> /// <summary>
/// 任务类型 /// 左侧出料口
/// </summary> /// </summary>
public string task_type { get; set; } static void releaseLeft()
} {
if (RobotManage.mainMachine.LeftMoveInfo.MoveStep == MoveStep.Wait)
{
//MessageBox.Show(crc.GetString("Res0018", "料串已是释放状态"));
return;
}
else if (RobotManage.mainMachine.SafeReleaseLeftShelf)
{
// MessageBox.Show(crc.GetString("Res0019", "正在执行料串释放"));
return;
}
else if (RobotManage.mainMachine.LeftMoveInfo.MoveStep < MoveStep.L04 || RobotManage.mainMachine.LeftMoveInfo.MoveStep > MoveStep.L30_LabelFinish)
{
//MessageBox.Show(crc.GetString("Res0083", "左侧料串正在提升或下降, 不能释放"));
return;
}
RobotManage.mainMachine.SafeReleaseLeftShelf = true;
Task.Run(() => {
int timeout = 2 * 60;
while (RobotManage.mainMachine.SafeReleaseLeftShelf && timeout > 0)
{
Task.Delay(500).Wait();
timeout--;
if ((RobotManage.mainMachine.LeftMoveInfo.MoveStep == MoveStep.L20_WaitLabel || RobotManage.mainMachine.LeftMoveInfo.MoveStep == MoveStep.L10_WaitReelPut) && (RobotManage.mainMachine.RightMoveInfo.MoveStep == MoveStep.Wait || RobotManage.mainMachine.RightMoveInfo.MoveStep == MoveStep.REND))
{
RobotManage.mainMachine.LeftMoveInfo.NextMoveStep(MoveStep.L30_LabelFinish);
}
}
RobotManage.mainMachine.SafeReleaseLeftShelf = false;
});
}
static void releaseRight()
{
if (RobotManage.mainMachine.RightMoveInfo.MoveStep == MoveStep.Wait)
{
// MessageBox.Show(crc.GetString("Res0018", "料串已是释放状态"));
return;
}
else if (RobotManage.mainMachine.SafeReleaseRightShelf)
{
//MessageBox.Show(crc.GetString("Res0019", "正在执行料串释放"));
return;
}
else if (RobotManage.mainMachine.RightMoveInfo.MoveStep < MoveStep.R04 || RobotManage.mainMachine.RightMoveInfo.MoveStep > MoveStep.R11_NextReel)
{
//MessageBox.Show(crc.GetString("Res0086", "右侧料串当前没有就位, 不能释放"));
return;
}
RobotManage.mainMachine.SafeReleaseRightShelf = true;
//btn_releaserightshelf.BackColor = Color.OrangeRed;
Task.Run(() => {
int timeout = 2 * 60;
while (RobotManage.mainMachine.SafeReleaseRightShelf && timeout > 0)
{
Task.Delay(500).Wait();
timeout--;
}
RobotManage.mainMachine.SafeReleaseRightShelf = false;
});
}
}
public class TaskDto
{
/// <summary> /// <summary>
/// 斯坦得AGV可执行的任务类型 /// 任务编码
/// </summary> /// </summary>
public class STDTaskType public string task_code { get; set; }
{ /// <summary>
/// <summary> /// 任务类型
/// NS200 入料口上料任务 /// </summary>
/// </summary> public string task_type { get; set; }
public const string NS200_LOAD_B1 = "NS200_LOAD_B1"; }
/// <summary> /// <summary>
/// NS200 入料口下料任务 /// 斯坦得AGV可执行的任务类型
/// </summary> /// </summary>
public const string NS200_UNLOAD_B1 = "NS200_UNLOAD_B1"; public class STDTaskType
/// <summary> {
/// NS200 出料口上料任务 /// <summary>
/// </summary> /// NS200 入料口上料任务
public const string NS200_LOAD_B2 = "NS200_LOAD_B2"; /// </summary>
/// <summary> public const string NS200_LOAD_B1 = "NS200_LOAD_B1";
/// NS200 出料口下料任务 /// <summary>
/// </summary> /// NS200 入料口下料任务
public const string NS200_UNLOAD_B2 = "NS200_UNLOAD_B2"; /// </summary>
/// <summary> public const string NS200_UNLOAD_B1 = "NS200_UNLOAD_B1";
/// MIMO上料任务 /// <summary>
/// </summary> /// NS200 出料口上料任务
public const string MIMO_LOAD = "MIMO_LOAD"; /// </summary>
/// <summary> public const string NS200_LOAD_B2 = "NS200_LOAD_B2";
/// MIMO下料任务 /// <summary>
/// </summary> /// NS200 出料口下料任务
public const string MIMO_UNLOAD = "MIMO_UNLOAD"; /// </summary>
} public const string NS200_UNLOAD_B2 = "NS200_UNLOAD_B2";
public class TaskState /// <summary>
{ /// MIMO上料任务
public string task_code { get; set; } /// </summary>
public bool updated { get; set; } = false; public const string MIMO_LOAD = "MIMO_LOAD";
public string task_status { get; set; } = "CREATED"; /// <summary>
} /// MIMO下料任务
/// </summary>
public const string MIMO_UNLOAD = "MIMO_UNLOAD";
}
public class TaskState
{
public string task_code { get; set; }
public bool updated { get; set; } = false;
public string task_status { get; set; } = "CREATED";
}
} }
...@@ -13,7 +13,7 @@ namespace DeviceLibrary.AGVService.Controllers ...@@ -13,7 +13,7 @@ namespace DeviceLibrary.AGVService.Controllers
/// 任务执行通知 /// 任务执行通知
/// </summary> /// </summary>
[RoutePrefix("nepconSmf/notification")] [RoutePrefix("nepconSmf/notification")]
public class taskNotificationController : ApiController public class notificationController : ApiController
{ {
[HttpPost] [HttpPost]
public RtnData taskStatus([FromBody] NotificationDto dto) public RtnData taskStatus([FromBody] NotificationDto dto)
......
...@@ -8,7 +8,7 @@ namespace DeviceLibrary.AGVService.Schemas ...@@ -8,7 +8,7 @@ namespace DeviceLibrary.AGVService.Schemas
{ {
public class RtnData public class RtnData
{ {
public int code { get; set; } = 0; public int code { get; set; } = 200;
public object data { get; set; } public object data { get; set; }
public string msg { get; set; } = "ok"; public string msg { get; set; } = "ok";
} }
......
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="AGVService\Controllers\deviceOperateController.cs" /> <Compile Include="AGVService\Controllers\deviceOperateController.cs" />
<Compile Include="AGVService\Controllers\taskNotificationController.cs" /> <Compile Include="AGVService\Controllers\notificationController.cs" />
<Compile Include="AGVService\HttpService.cs" /> <Compile Include="AGVService\HttpService.cs" />
<Compile Include="AGVService\Schemas\DeviceCheckDto.cs" /> <Compile Include="AGVService\Schemas\DeviceCheckDto.cs" />
<Compile Include="AGVService\Schemas\NotificationDto.cs" /> <Compile Include="AGVService\Schemas\NotificationDto.cs" />
......
...@@ -46,23 +46,10 @@ namespace DeviceLibrary ...@@ -46,23 +46,10 @@ namespace DeviceLibrary
private void ServerConnectTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) private void ServerConnectTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{ {
if (Monitor.TryEnter(serverConnectTimer)) if (!server.StartsWith("http"))
{ return;
try SendLineStatus();
{
if (!server.StartsWith("http"))
return;
SendLineStatus();
}
catch (Exception ex)
{
LogUtil.error($"ServerConnectTimer_Elapsed:{ex}");
}
finally
{
Monitor.Exit(serverConnectTimer);
}
}
} }
public void StartConnectServer() public void StartConnectServer()
{ {
...@@ -164,29 +151,36 @@ namespace DeviceLibrary ...@@ -164,29 +151,36 @@ namespace DeviceLibrary
{ {
if (RobotManage.IsDebug) if (RobotManage.IsDebug)
return; return;
try
lock (serverclock)
{ {
bool printlog = false; lock (serverclock)
DateTime time = DateTime.Now;
//构建发送给服务器的对象
Operation lineOperation = getLineBoxStatus();
if (lineOperation.status != laststatus)
{ {
laststatus = lineOperation.status; bool printlog = false;
printlog = true; DateTime time = DateTime.Now;
} //构建发送给服务器的对象
Operation lineOperation = getLineBoxStatus();
Operation resultOperation = HttpHelper.Post(GetPostApi(), lineOperation, 700, printlog); if (lineOperation.status != laststatus)
//LogUtil.info(JsonHelper.SerializeObject(resultOperation.data)); {
ResultProcess(resultOperation); laststatus = lineOperation.status;
TimeSpan span = DateTime.Now - time; printlog = true;
if (span.TotalMilliseconds > 700) }
{
LogUtil.info(StoreName + "TimerProcess[" + span.TotalMilliseconds + "]"); Operation resultOperation = HttpHelper.Post(GetPostApi(), lineOperation, 700, printlog);
//LogUtil.info(JsonHelper.SerializeObject(resultOperation.data));
ResultProcess(resultOperation);
TimeSpan span = DateTime.Now - time;
if (span.TotalMilliseconds > 700)
{
LogUtil.info(StoreName + "TimerProcess[" + span.TotalMilliseconds + "]");
}
} }
} }
catch (Exception ex)
{
LogUtil.error("SendLineStatus",ex);
}
} }
public bool SendAgvLog(string msg) public bool SendAgvLog(string msg)
{ {
...@@ -198,7 +192,7 @@ namespace DeviceLibrary ...@@ -198,7 +192,7 @@ namespace DeviceLibrary
{ {
new AgvLogInfo(msg) new AgvLogInfo(msg)
}; };
LogUtil.info(JsonHelper.SerializeObject(operation)); //LogUtil.info(JsonHelper.SerializeObject(operation));
Operation resultOperation = HttpHelper.Post(GetPostApi(), operation, 5000); Operation resultOperation = HttpHelper.Post(GetPostApi(), operation, 5000);
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!