queryStatusController.cs
6.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
using DeviceLib.WebApi.Schemas;
using DeviceLibrary;
using DeviceLibrary.AGVService.Schemas;
using log4net.Util;
using OnlineStore;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Web.Http;
using WebApi.Schemas;
namespace WebApi.Controllers
{
[RoutePrefix("api")]
public class queryStatusController : ApiController
{
[HttpGet]
public Result_20861 Get([FromBody] InParam_20861 body)
{
Result_20861 result = new Result_20861();
try
{
var cid = body.cid;
{
if (string.IsNullOrEmpty(cid))
{
result.code = 202;
result.status = "cid is empty";
}
else
{
if (body.cid.Equals("B1") || body.cid.Equals("B2"))
{
if (!RobotManage.isRunning)
{
result.code = 201;
result.status = crc.GetString("Res0079", "机器尚未启动不能呼叫Agv");
return result;
}
}
else
{
result.code = -1;
result.status = $" cid {body.cid} not exist";
}
//IS_RECEIVING 正在接收料串
//HAS_STACKER 有料串
//IS_DELIVERING 正在出料串
//EMPTY 无料串
//Error 错误
switch (body.cid)
{
case "B1"://NS200入料口上料任务
if (RobotManage.mainMachine.RightMoveInfo.IsStep(MoveStep.Wait))
{
if (RobotManage.mainMachine.IOValue(IO_Type.RightFornt_Check).Equals(IO_VALUE.HIGH)
|| RobotManage.mainMachine.IOValue(IO_Type.RightEnd_Check).Equals(IO_VALUE.HIGH))
{
result.status = "HAS_STACKER";
}
else
{
result.status = "EMPTY";
}
}
else
{
if (RobotManage.mainMachine.RightMoveInfo.MoveStep >= MoveStep.R40_InShelf)
{
result.code = 0;
result.status = "IS_RECEIVING";
}
else if (RobotManage.mainMachine.RightMoveInfo.MoveStep >= MoveStep.R30_OutShelf)
{
result.code = 0;
result.status = "IS_DELIVERING";
}
else if (RobotManage.mainMachine.IOValue(IO_Type.RightFornt_Check).Equals(IO_VALUE.HIGH)
|| RobotManage.mainMachine.IOValue(IO_Type.RightEnd_Check).Equals(IO_VALUE.HIGH))
{
result.status = "HAS_STACKER";
}
else
{
result.status = "EMPTY";
}
//{
// result.code = 203;
// result.status = "Error";
//}
}
break;
case "B2"://NS200出料口上料任务
if (RobotManage.mainMachine.LeftMoveInfo.IsStep(MoveStep.Wait))
{
if (RobotManage.mainMachine.IOValue(IO_Type.LeftFornt_Check).Equals(IO_VALUE.HIGH)
|| RobotManage.mainMachine.IOValue(IO_Type.LeftEnd_Check).Equals(IO_VALUE.HIGH))
{
result.status = "HAS_STACKER";
}
else
{
result.status = "EMPTY";
}
}
else
{
if (RobotManage.mainMachine.LeftMoveInfo.MoveStep >= MoveStep.L60_InShelf)
{
result.code = 0;
result.status = "IS_RECEIVING";
}
else if (RobotManage.mainMachine.LeftMoveInfo.MoveStep >= MoveStep.L50_OutShelf)
{
result.code = 0;
result.status = "IS_DELIVERING";
}
else
{
result.code = 203;
result.status = "Error";
}
}
break;
}
}
}
}
catch (Exception ex)
{
result.code = 204;
result.status = $"parse error:{ex.Message}";
LogUtil.error("QueryStatus", ex);
}
return result;
}
}
}