CommunicationForCenter.h 5.22 KB
#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