CommunicationForCenter.h
5.22 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#ifndef _COMMUNICATIONFORCENTER_H_
#define _COMMUNICATIONFORCENTER_H_
#include "bsp.h"
//-----------------------
#define STRING_SIZE 40 //字符串大小
#define LIST_SIZE 70
#define WifiBUFF_SIZE 400
#define ZIGBEEBUFF_SIZE_NEW 2000
#define ParamSize 400
#define NameSize 40
#define UART8BUFFSTRING 1400
typedef enum
{
teERR = 0,
teDecoding,
teDecodLost,
teDecodCRC,
teDecodSuccess
}ctDecodestate; //解碼狀態
//应答或则接收状态
typedef enum
{
sort_Send = 0, //发送
sort_Receive = 1,//接收
sort_Default, //位置状态
sort_Size
}teSendOrReplyType;//发送和回复类型
typedef enum
{
et_smtagv = 0, //agv
et_B123, //料架
et_B124, //充电机
et_A001,
et_A002,
et_A003,
et_Default, //未知设备
et_Size
}teEquipmentType;//设备类型
typedef enum
{
ct_rptac=0,
ct_getac ,
ct_getvol,
ct_geterr,
ct_getspd,
ct_getmt,
ct_rpterr,
ct_rptscan,
ct_rptmt,
ct_rptrtp,
ct_rptvol,
ct_rptvmot,
ct_rptin,
ct_rptlac,
ct_rptstart,
ct_rpttravel,
ct_rptmt_th,
ct_rptspd,
ct_rptmode,//手自动模式
ct_rptgo,
ct_rptpos,
ct_rptback,
ct_rtplayer,
ct_rptangle,
ct_releagv,
ct_callagv,
ct_settask,
ct_setrout,
ct_setstp,
ct_setspd,
ct_setrtp,
ct_settra,
ct_setmov,
ct_setvmot,
ct_setlock,
ct_setavoid,
ct_setmusic,
ct_setLaser,
ct_setout,
ct_setlrout,
ct_setlayer,
ct_setangle,
ct_delrtp,
ct_settcvoice,
ct_rptnode,
ct_rptline,//上报路线
ct_settips,//空闲放行
ct_print,
// ct_setreach,
ct_Default,
ct_Size
}teContentType;//运动状态
//数据重发机制结构体
typedef struct
{
//将以上状态字符复制到ReStructor.Matmes
char Matmes[ct_Size][STRING_SIZE];
/****************把所有的数据连成字符窜***********************/
//存储到Matmesseg
char Matmesseg[ct_Size][WifiBUFF_SIZE];
bool MatmesEnable[ct_Size];
int Matmestime[ct_Size];
uint8_t Matmes_Num[ct_Size];
}ResendStruct;
//--------------提取之前命令-----------------
typedef struct
{
char ReceiveData[ZIGBEEBUFF_SIZE_NEW];
char Cmd_List[LIST_SIZE][STRING_SIZE];//存储拆分后的参数
char Cmd_Lt[ZIGBEEBUFF_SIZE_NEW];
char Cmd_parameters[ParamSize][NameSize]; //分解后的参数(字符)
char Cmd_RoadParam[ZIGBEEBUFF_SIZE_NEW];
int Cmd_ListSize;
int Cmd_ParametersSize;
int RecesiveDate;//接收单次数据量
}tsCmdList;//命令提取之前的所有接收的字符
typedef struct
{
char Cmd_ListSize;//记录多少个解
char Cmd_List[7][30];//存储拆分后的参数
char Cmd_Dir[2];//存储对应的运动方向
char Cmd_RotateDir[2];//存储对应的旋转方向
int Cmd_parameters[3]; //分解后的参数(字符)
int land_mark_id;
}tsCmdListParam;//命令提取之前的所有接收的字符
//--------------提取後抽取出來分類後的命令-----------------
/******************************************
有效數據結構體成員 ~ (6個) !
方向(sendOrReply)
设备名称(equipmentType)
子模块(SubEquipmentType)
指令类型(dictateType)
动作(content)
参数(param)
*******************************************/
typedef struct
{
tsCmdListParam CmdListParam[50];//最多解析50条路径
tsCmdList CmdList;
teSendOrReplyType SendOrReply; //方向(sendOrReply)
teEquipmentType EquipmentType; //设备名称(equipmentType)
teContentType Content; //动作(content)
int Param[ParamSize]; //参数(param)
unsigned int Paramcount;
unsigned int RoadParamcount; ////道路参数计数
unsigned char RFIDCtrB;
unsigned char RFIDDIR;
unsigned short ID_CountryB;
int RandomID;
bool NewReceive;
unsigned int ReadyStopCtronl[2];
}tsCommand;//提取之後的有效命令
//保存系统下发路径
typedef struct
{
float pose[3];//坐标
u8 LaserArea;//雷达区域
short Direction;//方向
int DispatchSpeed;//调度速度
u8 LightStopSig;//对接信号
u8 RunState;//0沿0度方向 1沿90度方向 2沿180度方向 3沿270度方向
int LandMarkID;
}LandMark;//底盘控制信号
typedef struct
{
char SendLineEndIDSig;
char ChargingState;
int size;
int curr_id;
LandMark land_marks[LIST_SIZE];
}TrafficLandMarks;
extern TrafficLandMarks traffic_land_marks;
extern char Original_Command_String[ZIGBEEBUFF_SIZE_NEW];
extern char ParamBuff[40];
extern char GeCmddate[20];
extern ResendStruct ReStructor;
extern tsCommand CenterCommand;
//extern bool bk;
//解碼接收到的中控
//接收到的字符串,解碼並拆填充到iList
ctDecodestate CenterDecode(char Byte, tsCmdList* iList);
uint16_t AddCheckSum(char* cBuffer, short iBufLen);
int GetKeyWords(tsCmdList * iList);
int Getparameters(tsCmdList * iList);
char CommandAnalysis(void);
void SendOrReplyTypeHandle(void);
void Bady_DictateTypeHandle(void);
/***************************************************
车体动作/查询/握手
***************************************************/
void Create_BodyTreaty(bool AskAgainEnable,teEquipmentType EquipmentType ,teSendOrReplyType SendOrReplyType, teContentType ContentType, char *Parameter);
char* ParameterTransform(char *fmt, ...);
int vspf(char *fmt, ...);
void SysACKcheck(void);
void Recive_check(void);
uint16_t AddCheckSumCRC(char* cBuffer, short iBufLen);
int GetKeyWordschar(tsCmdListParam * iList,char *cmd,const char *str);
extern char Uart8SendBuff[UART8BUFFSTRING];
void UartReceiveDataFromSystem();
#endif