GetSendData.cs
4.83 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
using XingYe_ACS.BaseStruct;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace XingYe_ACS.Common
{
public class GetSendData
{
/// <summary>
/// 获取新动作
/// </summary>
/// <param name="agvMsg">小车信息</param>
/// <param name="listMotion">动作列表</param>
/// <returns></returns>
public static byte[] GetNewActionData(int intSonTaskNo, List<ClientMotion> listMotion)
{
byte[] Data = new byte[73];
Data[0] = 69;
//任务号
byte[] TaskNo = new byte[4];
TaskNo = BitConverter.GetBytes(UInt32.Parse(intSonTaskNo.ToString()));
Data[1] = TaskNo[0];
Data[2] = TaskNo[1];
Data[3] = TaskNo[2];
Data[4] = TaskNo[3];
//手动控制
if (listMotion == null)
{
//关机
if (intSonTaskNo == 21) { Data[5] = 21; }
//手动控制
//1代表开始手动动作;0代表结束当前动作
if (intSonTaskNo != 0) Data[71] = 1;
else
{
Data[71] = (byte)intSonTaskNo;
}
//手动控制动作类型
Data[72] = (byte)intSonTaskNo;
for (int i = 1; i < 5; i++) { Data[i] = 0; }
}
else if (listMotion.Count != 0)
{
Data[5] = (byte)listMotion[0].intTaskType; //动作类型
int DTypeIndex = 0;
foreach (ClientMotion newMotion in listMotion)
{
byte[] BarCode1 = new byte[4];
byte[] DXpos = new byte[2];
byte[] DYpos = new byte[2];
byte[] DXdis = new byte[2];
byte[] DYdis = new byte[2];
UInt32 barCode1 = UInt32.Parse(newMotion.strBarcode); //码值
BarCode1 = BitConverter.GetBytes(barCode1);
Data[6 + DTypeIndex] = BarCode1[0];
Data[7 + DTypeIndex] = BarCode1[1];
Data[8 + DTypeIndex] = BarCode1[2];
Data[9 + DTypeIndex] = BarCode1[3];
Int16 xpos = (Int16)newMotion.intX; //X坐标
DXpos = BitConverter.GetBytes(xpos);
Data[10 + DTypeIndex] = DXpos[0];
Data[11 + DTypeIndex] = DXpos[1];
Int16 ypos = (Int16)newMotion.intY; //Y坐标
DYpos = BitConverter.GetBytes(ypos);
Data[12 + DTypeIndex] = DYpos[0];
Data[13 + DTypeIndex] = DYpos[1];
Int16 xdis = (Int16)newMotion.intXLength; //X间距
DXdis = BitConverter.GetBytes(xdis);
Data[14 + DTypeIndex] = DXdis[0];
Data[15 + DTypeIndex] = DXdis[1];
Int16 ydis = (Int16)newMotion.intYLength; //Y间距
DYdis = BitConverter.GetBytes(ydis);
Data[16 + DTypeIndex] = DYdis[0];
Data[17 + DTypeIndex] = DYdis[1];
Data[18 + DTypeIndex] = (byte)newMotion.intOriAgv;//车头方向
Data[19 + DTypeIndex] = (byte)newMotion.intPathPointType;//点属性
Data[20 + DTypeIndex] = (byte)newMotion.intAntiCollision;//防撞属性
Data[21 + DTypeIndex] = (byte)newMotion.intOriDial;//托盘属性
DTypeIndex = DTypeIndex + 16;
}
}
else
{
Data[5] = 99; //动作类型
string strFinish = string.Format("完成信号:", Data[5].ToString());
App.ExFile.MessageLog("FinishSign", strFinish);
}
Data[70] = ComnMethod.checkCode(Data, 71);
return Data;
}
public static byte[] GetBarcodeData(int intSonTaskNo, string Barcode)
{
byte[] Data = new byte[73];
Data[0] = 69;
Data[5] = (byte)103; //动作类型
byte[] BarCode1 = new byte[4];
UInt32 barCode1 = UInt32.Parse(Barcode); //码值
BarCode1 = BitConverter.GetBytes(barCode1);
Data[6] = BarCode1[0];
Data[7] = BarCode1[1];
Data[8] = BarCode1[2];
Data[9] = BarCode1[3];
return Data;
}
/// <summary>
/// 关机
/// </summary>
/// <returns></returns>
public static byte[] GetOffData()
{
byte[] Data = new byte[4];
Data[0] = 0;
Data[1] = 5;
Data[2] = 0;
Data[3] = ComnMethod.checkCode(Data, 4);
return Data;
}
}
}