#ifndef __SERVICE_CMDPREPROCESS_H_
#define __SERVICE_CMDPREPROCESS_H_

///预存指令总数
#define CMD_BEFORE_AMOUNT               8

///指令有效
#define CMD_BEFORE_ON   1
///指令无效
#define CMD_BEFORE_OFF  0

///指令保存状态
#define CMD_BEFORE_SAVE_ON      1
///指令保存到FLASH
#define CMD_BEFORE_SAVE_SAVE    2
///指令擦除
#define CMD_BEFORE_SAVE_ERASE   3
///非指令保存状态
#define CMD_BEFORE_SAVE_OFF     0

#define CMD_BEFORE_FLASH_ADD            0X007E0000//指令数据存入Flash的首地址
#define CMD_BEFORE_SAVE_FLASH_NUM       3//保存次数

typedef struct _PtzCmdBeforeData_ 
{
  unsigned char cmd_data[7];
  struct sockaddr_in cmd_from;//IP和端口
  socklen_t cmd_fromlen;//长度
  char cmd_dev;//指令来源通道号
  char swtich;
  unsigned int crc;//和效验
}PtzCmdBeforeData;

extern PtzCmdBeforeData BeforeData[CMD_BEFORE_AMOUNT + 1];//数组最后一位用来存储所有数据的效验码
extern unsigned char cmd_before_count;

unsigned int ptz_cmd_before_single_crc(PtzCmdBeforeData data);
unsigned int ptz_cmd_before_all_crc();
char ptz_cmd_before_data_save();
char ptz_cmd_before_data_erase();
char ptz_cmd_before_data_read();
char ptz_cmd_before_mode(char dev, PTZ_DATA_PACK *pack);
void ptz_cmd_before_start();
#endif