/*  Created: 2022/11/4 11:02:40
 *  Author:  wangzk zhengmengxing
 */ 

#include 	"AttCtrlMain.h"
#include	"..\PrjTelmMng\TelmMng.h"		/* 载荷异步包通知指令相关 */

/***********************************************************************/
sTaskInfo	*m_pZKTaskInfo;					/*任务结构指针,已经初始化完毕为未用*/

//安装矩阵
static const TYPE_CAL M_SSA[3][3] = {{0.3420F,-0.2114F,-0.9156F},{-0.9397F,-0.0769F,-0.3333F},{-0.0000F,0.9744F,-0.2250F}};
static const TYPE_CAL M_SSB[3][3] = {{1.0000F,0.0F, 0.0F},{0.0F,-0.2250F,-0.9744F},{0.0F,0.9744F,-0.2250F}};
//static const TYPE_CAL M_SSC[3][3] ={{0.3214F,-0.3420F,0.8830F},{-0.1170F,-0.9397F,-0.3214F},{0.9397F, 0.0000F,-0.3420F}};
static const TYPE_CAL M_SSC[3][3] ={{0.2962F,-0.5F,0.8138F},{-0.1710F,-0.8660F,-0.4698F},{0.9397F, 0.0000F,-0.3420F}};
//static const TYPE_CAL M_GYROA[3][3] = {{-0.0000F,1.0000F,-0.0000F} , {1.0000F,0.0000F,0.0000F},{0.0000F,0.0F,-1.0000F}};
//static const TYPE_CAL M_GYROB[3][3] = {{-0.0000F,1.0000F, -0.0000F},{1.0000F,0.0000F,0.0000F},{0.0000F,0.0F,-1.0000F}};
static const TYPE_CAL M_GYROA[3][3] = {{-1.0000F,0.0000F,0.0000F}, {0.0000F,1.0000F,0.0000F},{0.0000F,0.0F,-1.0000F}};
static const TYPE_CAL M_GYROB[3][3] = {{-1.0000F,0.0000F,0.0000F}, {0.0000F,1.0000F,0.0000F},{0.0000F,0.0F,-1.0000F}};

static const TYPE_CAL M_GYROC[3][3] = {{0.0000F,-1.0000F,0.0F},{1.0000F,0.0000F,0.0F},{0.0F,0.0F,1.0000F}};
static const TYPE_CAL M_aSSA[3][3] = { { 0.0F, -0.6427876F, 0.7660444F },{ 0.0F, -0.7660444F ,-0.6427876F },{ 1.0F, 0.0F ,0.0F } };			//模拟太敏A
static const TYPE_CAL M_aSSB[3][3] = { { 0.0F, -0.6427876F, -0.7660444F },{ 0.0F, 0.7660444F ,-0.6427876F },{ 1.0F, 0.0F ,0.0F } };			//模拟太敏B
static const TYPE_CAL M_aSSC[3][3] = { {-0.8660254F ,0.0F, 0.5F },{ 0.5F, 0.0F ,0.8660254F },{ 0.0F ,1.0F ,0.0F } };						//模拟太敏C
static const TYPE_CAL M_aSSD[3][3] = { {0.0F,0.8660254F, -0.5F },{ 0.0F, 0.5F ,0.8660254F },{ 1.0F ,0.0F ,0.0F } };							//模拟太敏D
static const TYPE_CAL M_aSSE[3][3] = { { 0.0F,1.0F, 0.0F },{ 1.0F,0.0F,0.0F },{ 0.0F, 0.0F ,-1.0F } };										//模拟太敏E
static const TYPE_CAL M_aSSF[3][3] = { { -1.0F,0.0F,0.0F },{ 0.0F,0.0F,1.0F},{ 0.0F,1.0F,0.0F } };
static const TYPE_CAL M_MAG1[3][3] = { { 1.0F,0.0F,0.0F },{ 0.0F,-1.0F,0.0F },{ 0.0F,0.0F,-1.0F } };										//磁强计安装矩阵
static const TYPE_CAL M_MAG2[3][3] = { { 1.0F,0.0F,0.0F },{ 0.0F,-1.0F,0.0F },{ 0.0F,0.0F,-1.0F } };										//磁强计安装矩阵
static const TYPE_CAL M_MAGCtrl[3][4] = { { 1.0F,0.0F,0.0F,0.0F },{ 0.0F,1.0F,0.0F,0.0F},{ 0.0F,0.0F,1.0F,1.0F} };							//磁力矩器安装矩阵
static const TYPE_CAL M_Wheel[3][4] = { { -1.0F,0.0F,0.0F,0.4912F },{ 0.0F,-1.0F,0.0F,-0.4912F},{ 0.0F,0.0F,-1.0F,-0.7193F} };	

/***********************************************
说明：用于星箭分离后 姿控敏感器和执行器加电
注意:
***********************************************/
void	ZKDptPowerOnPrc(void)
{
	sAttPriData *tmpAtt = NULL;	
	sTaskMngDataRecord   *tmpTaskMngDataRcd = NULL;
	
	tmpAtt=(sAttPriData *)ATTCLT_DATA1_ADDR;
	tmpTaskMngDataRcd = (sTaskMngDataRecord *)ST_TASKMNG_ADDR;
	
	if((NULL == tmpAtt) || (NULL == tmpTaskMngDataRcd))
	{
		return;
	}
	
	/*分离后加电，星务模块中连续判硬件分离标志5s后，设置软件分离标志为分离0x55， 此处判软分离标志连续5s*/
	if(0x55 != tmpTaskMngDataRcd->bSHDepart)
	{
		//ZKModDoSet(ATTMOD_BREAKPRE);
		tmpAtt->sModePara.ZKPowOnFirst = 0x55;
		tmpAtt->sModePara.WModCnt1 = 0;
	}
	else
	{
		if(tmpAtt->sModePara.WModCnt1 <= 60000)
			tmpAtt->sModePara.WModCnt1++;
	}
	
	/*卫星分离，加电电机：星敏感器A1/A2/B、磁强计A/B、陀螺A/B/C、GNSS、反作用轮X/Y/Z/S、SADA主份、电推*/
	if((0x55 == tmpTaskMngDataRcd->bSHDepart) /*分离 */
		&& (tmpAtt->sModePara.WModCnt1 >= 5)			  /*且 切判软件分离标志连续5s有效*/
		&& (0x55 == tmpAtt->sModePara.ZKPowOnFirst)      /*且 由未分离 到 分离 */
		)
	{
		if (0x00 == tmpAtt->sModePara.ZKPowOnStep)
		{
			//星敏A/B/C加电
			OCOut(OC74_STA_ON, 0, 16);
			OCOut(OC76_STB_ON, 0, 16);
			OCOut(OC78_STC_ON, 0, 16);
					
			//陀螺
			OCOut(OC66_GYROA_ON, 0, 16);
			OCOut(OC69_GYROB_ON, 0, 16);
			OCOut(OC71_GYROC_ON, 0, 16);
					
			//磁强计
			OCOut(OC94_CQJA_ON, 0, 16);
			OCOut(OC96_CQJB_ON, 0, 16);
			//GNS
			//OCOut(OC79_GNSSA_ON, 0, 16);
			//ZKModDoSet(ATTMOD_NOCOLL);
			tmpAtt->sModePara.ZKPowOnStep = 0x11;
		} 
		else if (0x11 == tmpAtt->sModePara.ZKPowOnStep)
		{
			//飞轮A加电
			OCOut(OC58_WHLX_ON, 0, 16);
			tmpAtt->sModePara.ZKPowOnStep = 0x22;
		}
		else if (0x22 == tmpAtt->sModePara.ZKPowOnStep)
		{
			//飞轮B加电
			OCOut(OC60_WHLY_ON, 0, 16);
			tmpAtt->sModePara.ZKPowOnStep = 0x33;
		}
		else if (0x33 == tmpAtt->sModePara.ZKPowOnStep)
		{
			//飞轮C加电
			OCOut(OC62_WHLZ_ON, 0, 16);	
			tmpAtt->sModePara.ZKPowOnStep = 0x44;		
		}
		else if (0x44 == tmpAtt->sModePara.ZKPowOnStep)
		{
			//飞轮D加电
			OCOut(OC64_WHLS_ON, 0, 16);
			tmpAtt->sModePara.ZKPowOnStep = 0x55;
			tmpAtt->sModePara.ZKPowOnFirst = 0x00;
		}
	}
}

/***********************************************
说明：初始化采集进程需要的硬件和软件
输入：无
输出：TRUE / FALSE
返回：初始化结果
注意：仅仅初始化各设备连接的数据采集部分
***********************************************/
BOOL	AttCtrlInit(UINT8 taskID)
{
	UINT8	i = 0x00;
	UINT8	j = 0x00;
	UINT8	k = 0x00;
	UINT8	PPUOff[8] = {0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
	BOOL	result = TRUE;

	#ifndef  MINMODULE_TYPE
		m_pZKTaskInfo = (sTaskInfo *)GetTaskInfoBT(taskID);
		if(NULL == m_pZKTaskInfo)
		{
			return FALSE;
		}    
	#endif

	sAttPriData *tmpAtt = NULL;	
	AttCtrlConst_t *tmpConst= NULL;		
	
	
	SsPara_t *PStar[STAR_NUM]= {NULL};	
	GyroPara_t *PGyro[GYRO_NUM]= {NULL};	
	MagPara_t *PMag = NULL;
	WhlPara_t *PWhl= NULL;
	MtPara_t *pMt= NULL;
	
	sAttErrCtlPara_t *pREcheck= NULL;
	sAttCtlPara_t *pCtrl= NULL;	
	sAttDeterPara_t *pDeter= NULL;
	sAttOrbitGetPara_t *pOrbitIn= NULL;
	AttIMPTPara_t *pImpt= NULL;
	sAttModPara_t *pWMod= NULL;
	sAttGuidLawPara_t *pGuide= NULL;	
	sAttOrbitCtlInfo_t *pOrb= NULL;	
	sAttOrbitCtlData_t *tmpOrbCmd= NULL;
	sAttTARCCtlData_t *tmpTARCmd= NULL;	
	sAttTARCCtlInfo_t *pTAR= NULL;
	PPUPara_t *PPPU= NULL;
	AttCmdDsp_t  *pCmdDsp= NULL;

	tmpAtt=(sAttPriData *)ATTCLT_DATA1_ADDR;
	tmpConst=(AttCtrlConst_t *)ATTCLT_DATA2_ADDR;
	tmpOrbCmd=(sAttOrbitCtlData_t *)ATTCLT_DATA3_ADDR;
	tmpTARCmd=(sAttTARCCtlData_t *)ATTCLT_DATA6_ADDR;	
	if(NULL == tmpAtt || NULL ==tmpConst || NULL ==tmpOrbCmd || NULL ==tmpTARCmd)
		return FALSE;			
	memset(tmpAtt, 0, sizeof(sAttPriData));	
	memset(tmpOrbCmd, 0, sizeof(sAttOrbitCtlData_t));	
	memset(tmpTARCmd, 0, sizeof(sAttTARCCtlData_t));	

	PStar[0] = &tmpAtt->sPerPara.SsPara[0];
	PStar[1] = &tmpAtt->sPerPara.SsPara[1];
	PStar[2] = &tmpAtt->sPerPara.SsPara[2];

	PGyro[0] = &tmpAtt->sPerPara.GyroPara[0];
	PGyro[1] = &tmpAtt->sPerPara.GyroPara[1];
	PGyro[2] = &tmpAtt->sPerPara.GyroPara[2];
	
	PMag = &tmpAtt->sPerPara.MagPara;
	PWhl = &tmpAtt->sPerPara.WhlPara;
	pREcheck = &tmpAtt->sErrCtlPara;
	pCtrl = &tmpAtt->sCtlPara;
	pMt = &tmpAtt->sPerPara.MtPara;
	pDeter = &tmpAtt->sDeterPara;
	pOrbitIn = &tmpAtt->sOrbitPara;
	pImpt = &tmpAtt->sIMPTPara;
	pWMod = &tmpAtt->sModePara;
	pGuide = &tmpAtt->sGuidLawPara;
	pOrb = &tmpAtt->sOrbitInp;
	pTAR = &tmpAtt->sTARCInp;
	PPPU = &tmpAtt->sPerPara.PPUPara;	
	pCmdDsp = &tmpAtt->sCmdDspPara;

	/*所有模块初始化*/
	ZKModInit();
	ZKEnvInit();
	ZKDPInit();
	ZKREInit();
	ZKDYInit();
	ZKPosCtlInit();

	memcpy(&(tmpConst->AttCmdFlashPara.M_SSA[0][0]), &M_SSA[0][0], 9*sizeof(TYPE_CAL));
	memcpy(&(tmpConst->AttCmdFlashPara.M_SSB[0][0]), &M_SSB[0][0], 9*sizeof(TYPE_CAL));
	memcpy(&(tmpConst->AttCmdFlashPara.M_SSC[0][0]), &M_SSC[0][0], 9*sizeof(TYPE_CAL));

	memcpy(&(tmpConst->AttCmdFlashPara.M_GYRO[0][0][0]), &M_GYROA[0][0], 9*sizeof(TYPE_CAL));
	memcpy(&(tmpConst->AttCmdFlashPara.M_GYRO[1][0][0]), &M_GYROB[0][0], 9*sizeof(TYPE_CAL));
	memcpy(&(tmpConst->AttCmdFlashPara.M_GYRO[2][0][0]), &M_GYROC[0][0], 9*sizeof(TYPE_CAL));
	
	memcpy(&(tmpConst->AttCmdFlashPara.M_aSSA[0][0]), &M_aSSA[0][0], 9*sizeof(TYPE_CAL));
	memcpy(&(tmpConst->AttCmdFlashPara.M_aSSB[0][0]), &M_aSSB[0][0], 9*sizeof(TYPE_CAL));
	memcpy(&(tmpConst->AttCmdFlashPara.M_aSSC[0][0]), &M_aSSC[0][0], 9*sizeof(TYPE_CAL));
	memcpy(&(tmpConst->AttCmdFlashPara.M_aSSD[0][0]), &M_aSSD[0][0], 9*sizeof(TYPE_CAL));
	memcpy(&(tmpConst->AttCmdFlashPara.M_aSSE[0][0]), &M_aSSE[0][0], 9*sizeof(TYPE_CAL));
	memcpy(&(tmpConst->AttCmdFlashPara.M_aSSF[0][0]), &M_aSSF[0][0], 9*sizeof(TYPE_CAL));
	memcpy(&(tmpConst->AttCmdFlashPara.M_MAG[0]),  &M_MAG1[0][0],  9*sizeof(TYPE_CAL));
	memcpy(&(tmpConst->AttCmdFlashPara.M_MAG[1]),  &M_MAG2[0][0],  9*sizeof(TYPE_CAL));
	memcpy(&(tmpConst->AttCmdFlashPara.M_Wheel[0][0]), &M_Wheel[0][0], 12*sizeof(TYPE_CAL));
	memcpy(&(tmpConst->AttCmdFlashPara.M_MAGCtrl[0][0]), &M_MAGCtrl[0][0], 12*sizeof(TYPE_CAL));
	
	//互校验阈值(可上注修改)
	tmpConst->Allow_Sensor_CThr = 0x55;//0;20240630
	tmpConst->SS_SS_CThr = 2.0*ANG2RADIAN;
	tmpConst->SS_ASS_CThr = 10.0*ANG2RADIAN;
	tmpConst->SS_ASS_CCThr = 10.0*ANG2RADIAN;
	tmpConst->SS_GYRO_CThr = 0.2*ANG2RADIAN;
	//tmpConst->SS_MAG_CThr = 3*ANG2RADIAN;
	tmpConst->AttCmdFlashPara.SS_MAG_CThr = 30*ANG2RADIAN;
	//tmpConst->MAG_MAG_CThr = 1000;
	tmpConst->MAG_MAG_CThr = 3000;      //200t230
	tmpConst->GYRO_GYRO_CThr = 0.1*ANG2RADIAN;
	
	//整星转动惯量
	tmpConst->SAT_J[0][0]=497.35;
	tmpConst->SAT_J[0][1]=0.0;
	tmpConst->SAT_J[0][2]=0.0;
	tmpConst->SAT_J[1][0]=0.0;
	tmpConst->SAT_J[1][1]=585.45;
	tmpConst->SAT_J[1][2]=0.0;
	tmpConst->SAT_J[2][0]=0.0;
	tmpConst->SAT_J[2][1]=0.0;
	tmpConst->SAT_J[2][2]=154.56;
	
	//模拟太敏D:
	for (i = 0; i < ASS_NUM; ++i)
	{
		pImpt->AssUseState[i]= POSE_OK;								//单个太敏可用标志 	
	}
	tmpConst->Ass_MinFour_limt[0] = 3.5;						//4片模拟太敏电压阈值
	tmpConst->Ass_MaxFour_limt[0] = 12.0;						//4片模拟太敏电压阈值
	tmpConst->Ass_MinFour_limt[1] = 3.5;						//EF片模拟太敏电压阈值
	tmpConst->Ass_MaxFour_limt[1] = 7.0;						//EF片模拟太敏电压阈值	
	//陀螺
	for (i = 0; i < GYRO_NUM; i++)
	{	
		PGyro[i]->Gyro_AvailableFlg=POSE_OK;
		for (k = 0; k < 3; k++)
		{
			PGyro[i]->Gyro_ComCnt[k] = 0;							//陀螺上下拍数据比较有效计数
			tmpConst->AttCmdFlashPara.Gyro_Comd_Bias[i][k] =0;						//陀螺零偏
			for (j = 0; j < 3; j++)
			{
				tmpConst->AttCmdFlashPara.Gyro_Comd_K[i][k][j] =0; 
			}
			tmpConst->AttCmdFlashPara.Gyro_Comd_K[i][k][k] =1; 
		}
		memset(PGyro[i]->GyroIn_SpeedPre, 0, 3*sizeof(TYPE_CAL));
		memset(PGyro[i]->GyroIn_Speed, 0, 3*sizeof(TYPE_CAL));
	}
		
	//星敏
	for (i = 0; i < 3; i++)
	{
		PStar[i]->ssAvailableFlg=POSE_OK;							//星敏可用标志
		PStar[i]->ssExpose_cnt=0;
		memset(PStar[i]->ssIn_Qpre, 0.0, 4*sizeof(TYPE_CAL));
		memset(PStar[i]->ssIn_Q, 0.0, 4*sizeof(TYPE_CAL));
	}
	
	//磁强计
	PMag->Mag_Use  = POSE_OK;
	PMag->Mag_UsePre = POSE_OK;
	pImpt->MagUseState[0] = POSE_OK;
	pImpt->MagUseState[1] = POSE_OK;

	memset(PMag->Mag_Bb,0.0,3*sizeof(TYPE_CAL));
	memset(PMag->Mag_BbPre,0.0,3*sizeof(TYPE_CAL));

	for (i = 0; i < MAG_NUM; i++)
	{								
		//PMag->MagIn_Valid[i]= POSE_OK;								//模拟磁强计A/B有效标志
		//输出量
		memset(PMag->Mag_Bc_MeaAB[i],0.0,3*sizeof(TYPE_CAL));
		memset(PMag->Mag_Bb_MeaAB[i],0.0,3*sizeof(TYPE_CAL));	
	}
		PMag->MagIn_DataSta= 0;		
	
	//飞轮相关注数
	for (i = 0; i < WHEEL_NUM; ++i)
	{
		tmpConst->Whl_J[i] = 0.0064;
		pImpt->Whl_Use[i]=POSE_OK;	
	}
	tmpConst->Whl_HCent[0]=0.5 * 0.7;
	tmpConst->Whl_HCent[1]=-0.5 * 0.7;
	tmpConst->Whl_HCent[2]=-0.732 * 0.7;
	tmpConst->Whl_HCent[3]=1.018 * 0.7;
	memset(PWhl->Whl_Rate,0,4*sizeof(TYPE_CAL));
	memset(PWhl->Whl_RatePre,0,4*sizeof(TYPE_CAL));
	memset(PWhl->Whl_Time,0,4*sizeof(UINT32));
	memset(PWhl->Whl_TimePRE,0,4*sizeof(UINT32));
	pCmdDsp->Wheel_Cmd_Cnt = 0;
	pREcheck->WhlUseState= 0x0f;
	PWhl->Whl_UseCnt=4;
	tmpConst->WheelD_NomSpeed = 2000;								//rpm
	tmpConst->WheelD_SpeedErrThr = 100;     //20230104
	tmpConst->WheelD_Default = 0.03;
	tmpConst->WheelD_AllDefault = 0.04;
	memset(PWhl->Whl_WorkMode, WHL_CMD_CODE_RATE, 4*sizeof(UINT8));
	tmpConst->Whl_ID[0]=0x01;
	tmpConst->Whl_ID[1]=0x01;
	tmpConst->Whl_ID[2]=0x01;
	tmpConst->Whl_ID[3]=0x01;	
		
#ifndef  MINMODULE_TYPE
	//PPU
	//tmpAtt->sErrCtlPara.AttPPUOnReq = POSE_NO;
	//tmpAtt->sErrCtlPara.AttPPUOffReq = POSE_NO;
	pImpt->PPUUseStatus=POSE_OK;
	pImpt->PPUSafeStatus=POSE_OK;
	PPPU->PPUOUT_Sta = POSE_IN;					//PPU 数据无效原因
	PPPU->PPUIn_ReCnt= 0;						//PPU遥测请求计数
	PPPU->PPUNoUse_Cnt= 0;
	PPPU->PPUIn_ReCntPre= 0;					//PPU上一拍遥测请求计数
	for (i = 0; i < 50; ++i)
	{
		PPPU->PPUT_FIR_Start[i] =i;
		PPPU->PPUT_FIR_End[i] = i;
	}	
	tmpConst->AttCmdFlashPara.PPUT_FIR_EndLast = 0;
		
	PPPU->PPUT_FIR_Sum = 0;	
	PPPU->PPUT_FIR_Cnt = 0;	
	PPPU->PPUT_FIR_CntS = 0;	
	PPPU->PPUT_FIR_SumCnt = 0;
	tmpConst->AttCmdFlashPara.WorkModeChangeAuto=POSE_NO;       //二次电话允许标准
	//tmpConst->AttCmdFlashPara.PPUPVK = 0.1065;
	//tmpConst->AttCmdFlashPara.PPUPAK = 0.000605;
	//tmpConst->AttCmdFlashPara.PPUPVB = -1.4477;
	//tmpConst->AttCmdFlashPara.PPUPAB = -0.0107;	
	tmpConst->AttCmdFlashPara.PPUPVK = 0.1;
	tmpConst->AttCmdFlashPara.PPUPAK = 0.001;
	tmpConst->AttCmdFlashPara.PPUPVB = 0.0;
	tmpConst->AttCmdFlashPara.PPUPAB = 0.0;
	PPPU->PPUIn_FIREOK = 0;					//点火成功标志
	PPPU->PPUIn_FIREOKPre = 0;				//点火成功标志	
	
	PPPU->PPU_OrbitCtl_Quit_OK_Flag = POSE_NO;		/*轨控正常退出标志*/
	PPPU->PPU_OrbitCtl_Quit_OK_Cnt = 0;		/*轨控正常退出节拍计数*/
	
	PPPU->PPU_OrbitCtl_Quit_Err_Flag = POSE_NO;		/*轨控异常退出标志*/
	PPPU->PPU_OrbitCtl_Quit_Err_Cnt = 0;		/*轨控正常异常节拍计数*/

#endif
	//磁力矩器
	tmpConst->Mag_Bb_CtrlMax=100.0;                                 //磁力矩器最大输出磁矩  50
	tmpConst->Mag_Kp[0]=0.001;										//比例微分系数为
	tmpConst->Mag_Kp[1]=0.001;										//比例微分系数为
	tmpConst->Mag_Kp[2]=0.001;										//比例微分系数为
	tmpConst->Mag_Kd[0]=2.4;
	tmpConst->Mag_Kd[1]=2.4;
	tmpConst->Mag_Kd[2]=2.4;	
	
	tmpConst->Mag_KpFBZK[0]=0.001;									//比例微分系数为
	tmpConst->Mag_KpFBZK[1]=0.001;									//比例微分系数为
	tmpConst->Mag_KpFBZK[2]=0.001;									//比例微分系数为
	tmpConst->Mag_KdFBZK[0]=2.4;
	tmpConst->Mag_KdFBZK[1]=2.4;
	tmpConst->Mag_KdFBZK[2]=2.4;	

	tmpConst->Mag_WTOSUN =-0.5*ANG2RADIAN;
	tmpConst->Mag_FBZKWTOSUN =0.3*ANG2RADIAN;
	tmpConst->Mag_ATTTOSUN =30.0 * ANG2RADIAN;
	tmpConst->Mag_DampBdotMin=10.0;                                 //磁控阻尼死区  10
	for (i = 0; i < MAG_NUM; ++i)
	{
		for (j = 0; j< 3; j++)
		{
			tmpConst->AttCmdFlashPara.MAG_LK[i][j]=28000.0;
			tmpConst->AttCmdFlashPara.MAG_LB[i][j]=-70000.0; 
		}
	}
	pMt->MTCtrlTime = 0;											//磁力矩器控制时间计数
	pMt->MTStatus = 0;	
	tmpConst->MTCtrlTIME=8;
	tmpConst->AttCmdFlashPara.Mag_ComRESW[0]=0x00;			    					//磁强计表头重构状态字
	tmpConst->AttCmdFlashPara.Mag_ComRESW[1]=0x00;			    					//磁强计表头重构状态字
	tmpConst->AttCmdFlashPara.Mag_ComRESW[2]=0x00;			    					//磁强计表头重构状态字
	pImpt->MTUseStatus[0]=POSE_OK;
	pImpt->MTUseStatus[1]=POSE_OK;
	pImpt->MTUseStatus[2]=POSE_OK;
	pImpt->MTUseStatus[3]=POSE_OK;
	tmpConst->MTOutXYZLimit[0] = 100.0;
	tmpConst->MTOutXYZLimit[1] = 100.0;
	tmpConst->MTOutXYZLimit[2] = 50.0;
	tmpConst->MTOutXYZLimit[3] = 50.0;

	//帆板
	pWMod->WModSadaOpen=POSE_NO;
	pWMod->MiniDataSet =POSE_OK;
	pWMod->WModSadaOpenPre=POSE_NO;	
	pWMod->ZKSadaOpen=POSE_NO;
	
	//磁卸载
	tmpConst->k1_dump = 0.5;
	tmpConst->k2_dump = 0.3;
	//tmpConst->ku_dump = 400000.0;
	tmpConst->ku_dump = 500000.0;
	tmpConst->MTAtt_dump = 45.0 *ANG2RADIAN ;
    //轨道计算
    pOrbitIn->OrbitVld=POSE_OK;
	memset(pOrbitIn->JPos,0,3*sizeof(TYPE_CAL));
	memset(pOrbitIn->JVel,0,3*sizeof(TYPE_CAL));
	pOrbitIn->MJC=0;		   											//儒略世纪
	pOrbitIn->MJCLv=POSE_NO;
	pOrbitIn->GAST=0;													//格林尼治恒星时角
     
	//PD控制
	memset(pDeter->CLPAttAngRat,0,3*sizeof(TYPE_CAL));
	memset(pDeter->CLPAttAngRatPre,0,3*sizeof(TYPE_CAL));
	
	//PID控制器相关参数清零
	memset(tmpAtt->sCtlPara.SumAerrPre, 0, 3*sizeof(TYPE_CAL));			//PID积分器清零
	memset(tmpAtt->sCtlPara.WheelCtrlResultPre, 0, 3*sizeof(TYPE_CAL));	//前次控制器指令记录结果清零
	tmpAtt->sCtlPara.PD2PIDCnt = 0;
	tmpAtt->sCtlPara.CtrlPD2PID =0;

#ifndef  MINMODULE_TYPE
	//轨道控制
	pOrb->CurOrbCtrlPcak_ID = 0x00;
	pOrb->CurOrbCtrlPcak_PreID =0xFF;
	pOrb->OrbDataIn_OK = POSE_NO;
	pOrb->OrbDataIn_OKCnt = 0x00;
	for (i = 0; i < 50; ++i)
	{	
		pOrb->OrbCtrlPcak_ReceiveFlg[i]= 0x00;
		memset(&tmpOrbCmd->OrbCtrlPack[i],0,sizeof(AttOrbCtrlPara_t));
	}
	memset(&pOrb->OrbCtrlPackCur,0,sizeof(AttOrbCtrlPara_t));
	//目标定向
	pTAR->CurTARCtrlPcak_ID = 0;
	pTAR->CurTARCtrlPcak_PreID = 0xFF;
	pTAR->TARDataIn_OK = POSE_NO;
	pTAR->TARDataIn_OKCnt = 0;
	for (i = 0; i < 30; ++i)
	{	
		pTAR->TARCtrlPcak_ReceiveFlg[i]= 0x00;
		memset(&tmpTARCmd->TARCtrlPack[i],0,sizeof(sAttTARCCtlPara_t));
	}	
#endif
		
	//定姿初始化
	memset(pDeter->Qi,0,4*sizeof(TYPE_CAL));
	memset(pDeter->Wi,0,3*sizeof(TYPE_CAL));
	memset(pDeter->QiPre,0,4*sizeof(TYPE_CAL));
	memset(pDeter->WiPre,0,3*sizeof(TYPE_CAL));
	pDeter->Qi_Vld = POSE_NO;							//卫星惯性系四元数有效标志
	pDeter->QiPre_Vld = POSE_NO;
	pDeter->PPUVld = POSE_NO;
	pDeter->Wi_Vld = POSE_OK;							//卫星惯性系角速度有效标志	
	tmpConst->GyroINT_TLimt = 2400;
	pDeter->GyroINT_Time= 0;

	//导引律初始化
	pGuide->CaptureSunCnt=0;

	//姿控初始化
	tmpConst->AccThru_Up[0]= 0;
	tmpConst->AccThru_Up[1]= 0;
	tmpConst->AccThru_Up[2]= -8.0E-5;	
	//姿态确定参数初始化
	tmpAtt->sCtlPara.IsDump = POSE_NO;
	
	//磁力矩器输出
	pCtrl->MagCtrlResult[0] =0.0;
	pCtrl->MagCtrlResult[1] =0.0;
	pCtrl->MagCtrlResult[2] =0.0;	
	pCtrl->MagCtrlXYZZ[0] =0.0;
	pCtrl->MagCtrlXYZZ[1] =0.0;	
	pCtrl->MagCtrlXYZZ[2] =0.0;	
	pCtrl->MagCtrlXYZZ[3] =0.0;		
	//tmpAtt->AttData3T2Para.AttCtlBKFlag = POSE_NO;
	//帆板flash数据初始化
	tmpAtt->ATSFlashPara.SHDepartCntlimt1 =0;  
	/*读取flash区间数据*/
	ATTRestoreFromFlash();
	
	/*三取二设置*/
	ATTImportDataBackup();
	
	/*重启/切机/复位 发送异常PPU关动作，不关电源只关点火*/
	dev_can_write(DEV_NO_CAN0, PPUOff, 8);
	PPPU->PPUOUT_Sta = POSE_NO;/*电推指令开关标志为关*/
	tmpAtt->sCtlPara.ZK_Ctrl_Reserver111 = POSE_NO;	
	///*重启/切机/复位 飞轮转速电流给0*/
	//SetWheel(1,0,WHL_CMD_CODE_CURR);
	//SetWheel(2,0,WHL_CMD_CODE_CURR);
	//SetWheel(3,0,WHL_CMD_CODE_CURR);
	//SetWheel(4,0,WHL_CMD_CODE_CURR);
	
	/*重启/切机/复位 输出磁力矩占控比为0*/
	magnetic_out(0x11, 0, 0, 0);
	magnetic_out(0x22, 0, 0, 0);
	magnetic_out(0x33, 0, 0, 0);
	magnetic_out(0x44, 0, 0, 0);

	
	return result;
}


/***********************************************
说明：姿控指令处理
***********************************************/
void ZKCmdResolve(void)
{
	UINT8		i= 0x00;
	UINT8		j= 0x00;
	UINT8		k= 0x00;
	UINT8		tmpCmd[MOD_REQ_MAXLEN]= {0x00};
	UINT8		tmpWhlCmd[MOD_REQ_MAXLEN]= {0x00};
	UINT16		tmpCmdCode = 0;			            //指令码
	UINT8		tmpOffset = 0x02;					//指令码偏移
	UINT8		*tmpData= 0x00;
	UINT8		tmpDevNO = 0x00;

	UINT32		tmpiDataLength= 0x00;				/*数据长度*/
	UINT32		tmpiDataLength1= 0x00;				/*数据长度*/
	UINT16		tmpiDataType =0;					/*数据类型*/
	UINT16		tmpiDataCheck=0;					/*数据校验和*/
	UINT16		tmpiDataCheck1=0;					/*数据校验和*/

	TYPE_CAL	tmpWlimit=0.0;
	TYPE_CAL	tmpAlimit=0.0;
	TYPE_CAL	tmpAngm=0.0;
	UINT16		tmpTimeLmt=0;
	UINT16      tmpTimeLmt1=0;
	UINT8		tmpWorkMod= 0x00;
	UINT8		tmpWorkModPre= 0x00;
	UINT8		tmpCOMDCHOICE= 0x00;
	UINT32		SatTime[2]= {0x00,0x00};
	TYPE_CAL	DETLTime1= 0.0;
	TYPE_CAL	DETLTime2= 0.0;
	UINT8 PPUOff[8]	= {0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

	sTaskMngDataRecord * tmpTaskMngDataRcd = NULL;
	sAttPriData *tmpAtt= NULL;	
	AttCtrlConst_t *tmpConst= NULL;	
	sAttOrbitCtlData_t *tmpOrbCmd= NULL;
	sAttTARCCtlData_t *tmpTARCCmd= NULL;	
	sAttOrbitCtlInfo_t *pOrb= NULL;	
	sAttTARCCtlInfo_t *pTARC= NULL;	
	sAttModPara_t *pWMod= NULL;	
	AttIMPTPara_t *pIMU= NULL;
	PPUPara_t *PPPU= NULL;		
	sTaskInfo *tmpCollectInfo = (sTaskInfo *)GetTaskInfoBT(TASK_COLLECT);	
	tmpTaskMngDataRcd = (sTaskMngDataRecord *)ST_TASKMNG_ADDR;
	tmpAtt=(sAttPriData *)ATTCLT_DATA1_ADDR;
	tmpConst=(AttCtrlConst_t *)ATTCLT_DATA2_ADDR;
	tmpOrbCmd=(sAttOrbitCtlData_t *)ATTCLT_DATA3_ADDR;
	tmpTARCCmd=(sAttTARCCtlData_t *)ATTCLT_DATA6_ADDR;
	if((NULL == tmpAtt) || (NULL ==tmpConst) || (NULL ==tmpOrbCmd) || (NULL ==tmpTARCCmd)|| (NULL ==tmpCollectInfo)|| (NULL ==tmpTaskMngDataRcd))
	{
		return ;
	}
	pOrb=&tmpAtt->sOrbitInp;
	pTARC=&tmpAtt->sTARCInp;
	pIMU=&tmpAtt->sIMPTPara;
	pWMod=&tmpAtt->sModePara;	
	PPPU = &tmpAtt->sPerPara.PPUPara;

	while(BlockRingGet(&(m_pZKTaskInfo->sCmdBuffer), tmpCmd, TRUE))
	{
		/*处理每个命令*/
		tmpCmdCode = DoGetInt16From8(tmpCmd + tmpOffset);
		m_pZKTaskInfo->iCmdLast = tmpCmdCode;
		m_pZKTaskInfo->iCmdRes = ERR_CODE_NOERR;
		m_pZKTaskInfo->iCmdCount++;
		//获取注数缓存地址
		tmpData=(UINT8*)(tmpCmd + tmpOffset +2);
		
		switch(tmpCmdCode)
		{
			/****************安全模式软指令*************************/			
			case ATT_SAFEMODE_SAFE1://整星安全模式1
			{			
				pOrb->CurOrbCtrlPcak_ID = 0x00;
				pOrb->CurOrbCtrlPcak_PreID =0xFF;
				PPPU->PPUT_FIR_Cnt = 0;
				pOrb->OrbDataIn_OK = POSE_NO;
				for (i = 0; i < 50; ++i)
				{
					pOrb->OrbCtrlPcak_ReceiveFlg[i]= 0x00;
					memset(&tmpOrbCmd->OrbCtrlPack[i],0,sizeof(AttOrbCtrlPara_t));
				}
				memset(&pOrb->OrbCtrlPackCur,0,sizeof(AttOrbCtrlPara_t));
					
				pIMU->PPUUseStatus=POSE_NO;
				pIMU->PPUSafeStatus=POSE_NO;
				PPPU->PPUOUT_Sta = POSE_NO;/*电推指令开关标志为关*/				
				tmpAtt->sCtlPara.ZK_Ctrl_Reserver111 = POSE_NO;	
				if ((ATTMOD_ATTAJUSTPRE == pWMod->WorkMode)||(ATTMOD_ORBITCTL == pWMod->WorkMode))
				{
					/*设置工作模式 速率阻尼*/					
					ZKModDoSet(ATTMOD_RATEDMP);			
				}
				break;
			}

			case ATT_SAFEMODE_SAFE2://整星安全模式2
			{
				/*设置工作模式 速率阻尼*/
				ZKModDoSet(ATTMOD_RATEDMP);
				pOrb->CurOrbCtrlPcak_ID = 0x00;
				pOrb->CurOrbCtrlPcak_PreID =0xFF;
				PPPU->PPUT_FIR_Cnt = 0;	
				pOrb->OrbDataIn_OK = POSE_NO;
				for (i = 0; i < 50; ++i)
				{	
					pOrb->OrbCtrlPcak_ReceiveFlg[i]= 0x00;
					memset(&tmpOrbCmd->OrbCtrlPack[i],0,sizeof(AttOrbCtrlPara_t));
				}
				memset(&pOrb->OrbCtrlPackCur,0,sizeof(AttOrbCtrlPara_t));
				
				pIMU->PPUUseStatus=POSE_NO;	
				pIMU->PPUSafeStatus=POSE_NO;
				PPPU->PPUOUT_Sta = POSE_NO;/*电推指令开关标志为关*/
				tmpAtt->sCtlPara.ZK_Ctrl_Reserver111 = POSE_NO;	
				break;
			}

			case ATT_SAFEMODE_SAFE3://整星安全模式3
			{
				/*设置工作模式 磁控对日*/
				ZKModDoSet(ATTMOD_MagTOSUN);		
				pOrb->CurOrbCtrlPcak_ID = 0x00;
				pOrb->CurOrbCtrlPcak_PreID =0xFF;
				PPPU->PPUT_FIR_Cnt = 0;
				pOrb->OrbDataIn_OK = POSE_NO;	
				for (i = 0; i < 50; ++i)
				{	
					pOrb->OrbCtrlPcak_ReceiveFlg[i]= 0x00;
					memset(&tmpOrbCmd->OrbCtrlPack[i],0,sizeof(AttOrbCtrlPara_t));
				}
				memset(&pOrb->OrbCtrlPackCur,0,sizeof(AttOrbCtrlPara_t));
				
				pIMU->PPUUseStatus=POSE_NO;	
				pIMU->PPUSafeStatus=POSE_NO;
				PPPU->PPUOUT_Sta = POSE_NO;/*电推指令开关标志为关*/
				tmpAtt->sCtlPara.ZK_Ctrl_Reserver111 = POSE_NO;	
				break;
			}			
			
			/**********************************模式控制指令*********************************/
			//速率阻尼 0X22  
			case ATT_CMDMODE_MODSUNCAP:
			{
				if(0x55 == tmpTaskMngDataRcd->bSHDepart)
				{
					/*设置工作模式 速率阻尼*/
					ZKModDoSet(ATTMOD_RATEDMP);
					if(0xAA55 == DoGetInt16From8(tmpData))
					{
						pOrb->CurOrbCtrlPcak_ID = 0;
						pOrb->CurOrbCtrlPcak_PreID =0xFF;
						PPPU->PPUT_FIR_Cnt = 0;
						memset(&tmpAtt->sOrbitInp.OrbCtrlPackCur, 0, sizeof(AttOrbCtrlPara_t));
						memset(&tmpOrbCmd->OrbCtrlPack, 0, 50*sizeof(AttOrbCtrlPara_t));
						pOrb->OrbDataIn_OK = POSE_NO;
						/*清轨道包，当前拍的关PPU动作*/
						dev_can_write(DEV_NO_CAN0, PPUOff, 8);
						PPPU->PPUOUT_Sta = POSE_NO;/*电推指令开关标志为关*/
						tmpAtt->sCtlPara.ZK_Ctrl_Reserver111 = POSE_NO;							
						pTARC->CurTARCtrlPcak_ID=0;
						pTARC->CurTARCtrlPcak_PreID =0xFF;
						memset(&tmpAtt->sTARCInp.TARCtrlPackCur, 0, sizeof(sAttTARCCtlPara_t));
						memset(&tmpTARCCmd->TARCtrlPack, 0, 30*sizeof(sAttTARCCtlPara_t));
						pTARC->TARDataIn_OK = POSE_NO;
					}
				}
				else
				{
					m_pZKTaskInfo->iCmdRes = ERR_CODE_CMDCODE;	/*指令失败*/
				}
				break;
			}
			//轮控对日定向0X33
			case ATT_CMDMODE_WhlTOSUN:
			{
				if(0x55 == tmpTaskMngDataRcd->bSHDepart)
				{
					/*设置工作模式 轮控对日*/
					ZKModDoSet(ATTMOD_WhlTOSUN);
				}
				else
				{
					m_pZKTaskInfo->iCmdRes = ERR_CODE_CMDCODE;	/*指令失败*/
				}
				break;
			}
			//磁控对日定向0X44
			case ATT_CMDMODE_MagTOSUN:
			{
				if(0x55 == tmpTaskMngDataRcd->bSHDepart)
				{
					/*设置工作模式 磁控对日*/
					ZKModDoSet(ATTMOD_MagTOSUN);
				}
				else
				{
					m_pZKTaskInfo->iCmdRes = ERR_CODE_CMDCODE;	/*指令失败*/
				}
				break;
			}
			//对地定向0X55
			case ATT_CMDMODE_ONLTOEARTH:
			{
				if(0x55 == tmpTaskMngDataRcd->bSHDepart)
				{
					if((ATTMOD_RATEDMP == pWMod->WorkMode)
					    ||(ATTMOD_WhlTOSUN == pWMod->WorkMode)
						||(ATTMOD_MagTOSUN == pWMod->WorkMode)
						||(ATTMOD_ATTAJUSTPRE == pWMod->WorkMode)
						||(ATTMOD_ORBITCTL == pWMod->WorkMode)
						||(ATTMOD_ATTAJUST == pWMod->WorkMode)
						||(ATTMOD_ONLTOTAR == pWMod->WorkMode)
						)
					{
						/*设置工作模式 对地定向*/
						ZKModDoSet(ATTMOD_ONLTOEARTH);
					}
					else
					{
						m_pZKTaskInfo->iCmdRes = ERR_CODE_CMDCODE;	/*指令失败*/
					}
				}
				else
				{
					m_pZKTaskInfo->iCmdRes = ERR_CODE_CMDCODE;	/*指令失败*/
				}
				break;
			}
			//稳态对地0X66
			case ATT_CMDMODE_WHEELTOEARTH:
			{
				if(0x55 == tmpTaskMngDataRcd->bSHDepart)
				{
					if((ATTMOD_ONLTOEARTH == pWMod->WorkMode)
						||(ATTMOD_ORBITCTL == pWMod->WorkMode)
						||(ATTMOD_ONLTOTAR == pWMod->WorkMode)
						)
					{
						/*设置工作模式 稳态对地*/
						ZKModDoSet(ATTMOD_WHEELTOEARTH);
					}
					else
					{
						m_pZKTaskInfo->iCmdRes = ERR_CODE_CMDCODE;	/*指令失败*/
					}
				}
				else
				{
					m_pZKTaskInfo->iCmdRes = ERR_CODE_CMDCODE;	/*指令失败*/
				}
				break;
			}
			//无控模式0XBB
			case ATT_CMDMODE_UNCTL:
			{
				if(0x55 == tmpTaskMngDataRcd->bSHDepart)
				{					
					if((ATTMOD_WhlTOSUN == pWMod->WorkMode)
						||(ATTMOD_MagTOSUN == pWMod->WorkMode)
						||(ATTMOD_RATEDMP == pWMod->WorkMode)
						)
					{
						/*设置工作模式 无控*/
						ZKModDoSet(ATTMOD_UNCTL);
					}
					else
					{
						m_pZKTaskInfo->iCmdRes = ERR_CODE_CMDCODE;	/*指令失败*/
					}
				}
				else
				{
					m_pZKTaskInfo->iCmdRes = ERR_CODE_CMDCODE;	/*指令失败*/
				}
				break;
			}
			case ATT_WORKMODE_ORBITCTLPRE:			//轨控前调姿(0x3606
				if((ATTMOD_WhlTOSUN == pWMod->WorkMode)/*当前模式为轮控对日*/
					||(ATTMOD_WHEELTOEARTH == pWMod->WorkMode)/*当前模式为稳定对地*/
					||(ATTMOD_ORBITCTL == pWMod->WorkMode)
				)
				{
					/*设置工作模式 轨控前调姿*/
					ZKModDoSet(ATTMOD_ATTAJUSTPRE);
				}
				else
				{
					m_pZKTaskInfo->iCmdRes = ERR_CODE_CMDCODE;	/*指令失败*/
				}
			break;
			case ATT_WORKMODE_ORBITCTL	:	    	//轨控(0x3607)
				if(ATTMOD_ATTAJUSTPRE == pWMod->WorkMode)/*当前模式为轨控前调姿*/
				{
					/*设置工作模式 轨控*/
					ZKModDoSet(ATTMOD_ORBITCTL);
				}
				else
				{
					m_pZKTaskInfo->iCmdRes = ERR_CODE_CMDCODE;	/*指令失败*/
				}
			break;
			case ATT_WORKMODE_ATTAJUST			:	/*(0x3611)	定向调姿*/
				if((ATTMOD_WhlTOSUN == pWMod->WorkMode)/*当前模式为轮控对日*/
				||(ATTMOD_WHEELTOEARTH == pWMod->WorkMode)/*当前模式为稳定对地*/
				||(ATTMOD_ONLTOTAR == pWMod->WorkMode)
				)
				{
					/*设置工作模式 定向前调姿*/
					ZKModDoSet(ATTMOD_ATTAJUST);
				}
				else
				{
					m_pZKTaskInfo->iCmdRes = ERR_CODE_CMDCODE;	/*指令失败*/
				}
			break;
			case ATT_WORKMODE_ONLTOTAR		    :	/*(0x3612)	目标定向*/
				if(ATTMOD_ATTAJUST == pWMod->WorkMode)/*当前模式为定向前调姿*/
				{
					/*设置工作模式 对目标定向*/
					ZKModDoSet(ATTMOD_ONLTOTAR);
				}
				else
				{
					m_pZKTaskInfo->iCmdRes = ERR_CODE_CMDCODE;	/*指令失败*/
				}
			break;
			
			//轨道控制数据包上注
			case ATT_CMDMODE_ORBITCTL:
			{
				tmpData=(UINT8*)(ATTCLT_DATA5_ADDR);
				GetTime(SatTime);	 
                memcpy(&(tmpiDataLength), tmpData, 4);
                memcpy(&(tmpiDataType), tmpData+ 4, 2);
                memcpy(&(tmpiDataCheck), tmpData+ 6, 2);

				for (i = 0; i < 50; ++i)
				{
					pOrb->OrbCtrlPcak_ReceiveFlg[i]= 0x00;
					memset(&tmpOrbCmd->OrbCtrlPack[i],0,sizeof(AttOrbCtrlPara_t));
				}
				tmpiDataLength1 = 1200;
				if ( tmpiDataLength1 != tmpiDataLength)
				{
					pOrb->OrbDataIn_OK = 0x01;
					PPPU->PPUT_FIR_Cnt = 0;
					return ;					
				}
				
                tmpiDataCheck1 =DoGetCheckSum(tmpData + sizeof(sSaveDataHead), tmpiDataLength);				
				
				if ((0x26==tmpiDataType)&&(tmpiDataCheck == tmpiDataCheck1))
				{
					pOrb->CurOrbCtrlPcak_ID = 0x00;
					pOrb->CurOrbCtrlPcak_PreID = 0xFF ;
					PPPU->PPUT_FIR_Cnt = 0;
					pOrb->OrbDataIn_OK = 0x55;
					for (i = 0; i < 50; ++i)
					{
						PPPU->PPUT_FIR_Start[i] =0;
						PPPU->PPUT_FIR_End[i] = 0;
					}
					tmpConst->AttCmdFlashPara.PPUT_FIR_EndLast = 0;
					pWMod->ATTFlashSwitch = POSE_OK;
					PPPU->PPUT_FIR_Cnt = 0;	
					PPPU->PPUT_FIR_CntS = 0;					

							
					for (i = 0; i < 50; i++)
					{   
						memcpy(&(tmpDevNO), tmpData + i * 24 + sizeof(sSaveDataHead) , sizeof(UINT8));
						if ((tmpDevNO>=1)&&(tmpDevNO<=50)&&(i +1==tmpDevNO))
						{
							//拷贝数据
							memcpy(&(tmpOrbCmd->OrbCtrlPack[tmpDevNO-1].OrbCtrlPcak_ID), (UINT8*)(tmpData + i * 24+ sizeof(sSaveDataHead)), sizeof(UINT8));
							tmpOrbCmd->OrbCtrlPack[tmpDevNO-1].OrbAttAjustTime=DoGetInt32From8(tmpData + i * 24 + sizeof(sSaveDataHead) +1);
							tmpOrbCmd->OrbCtrlPack[tmpDevNO-1].OrbCtrAng[0]= DoGetFloatFrom8(tmpData + i * 24 + sizeof(sSaveDataHead) +5);
							tmpOrbCmd->OrbCtrlPack[tmpDevNO-1].OrbCtrAng[1]= DoGetFloatFrom8(tmpData + i * 24 + sizeof(sSaveDataHead) +9);
							tmpOrbCmd->OrbCtrlPack[tmpDevNO-1].OrbCtrAng[2]= DoGetFloatFrom8(tmpData + i * 24 + sizeof(sSaveDataHead) +13);
							tmpOrbCmd->OrbCtrlPack[tmpDevNO-1].OrbCtrl_StartTime=DoGetInt32From8(tmpData + i * 24 + sizeof(sSaveDataHead) +17);
							tmpOrbCmd->OrbCtrlPack[tmpDevNO-1].OrbCtrl_TimeLength=DoGetInt16From8(tmpData + i * 24 + sizeof(sSaveDataHead) +21);
							memcpy(&(tmpOrbCmd->OrbCtrlPack[tmpDevNO-1].OrbCtrl_Mod), (UINT8*)(tmpData + i * 24 + sizeof(sSaveDataHead) +23), sizeof(UINT8));
							
							tmpOrbCmd->OrbCtrlPack[tmpDevNO-1].OrbDateSum =DoGetCheckSum(&(tmpOrbCmd->OrbCtrlPack[tmpDevNO-1].OrbCtrlPcak_ID), 24);
							pOrb->OrbCtrlPcak_ReceiveFlg[tmpDevNO-1]=0x55 ;
							
						}
					}
					
					if ((tmpOrbCmd->OrbCtrlPack[0].OrbAttAjustTime > SatTime[0])&&(tmpOrbCmd->OrbCtrlPack[0].OrbCtrl_StartTime > SatTime[0]))
					{
						PPPU->PPUT_FIR_Cnt = 1;
						for (i = 1; i < 50; i++)
						{
							if (0x55 == pOrb->OrbCtrlPcak_ReceiveFlg[i])
							{
								PPPU->PPUT_FIR_Cnt = i +1;
								DETLTime1 = (TYPE_CAL)tmpOrbCmd->OrbCtrlPack[i].OrbAttAjustTime - (TYPE_CAL)tmpOrbCmd->OrbCtrlPack[i -1].OrbCtrl_StartTime - (TYPE_CAL)tmpOrbCmd->OrbCtrlPack[i -1].OrbCtrl_TimeLength;
								DETLTime2 = (TYPE_CAL)tmpOrbCmd->OrbCtrlPack[i].OrbCtrl_StartTime - (TYPE_CAL)tmpOrbCmd->OrbCtrlPack[i].OrbAttAjustTime;
								if ((DETLTime1 < 0.0)|| (DETLTime2 < 0.0))
								{
									pOrb->OrbDataIn_OK = 0x02;
									PPPU->PPUT_FIR_Cnt = 0;
									PPPU->PPUT_FIR_CntS = 0;
									break;
								}
							}
							else
							{
								break;
							}
						}							
					}
					else
					{
						PPPU->PPUT_FIR_Cnt = 0;
						PPPU->PPUT_FIR_CntS = 0;
						pOrb->OrbDataIn_OK = 0x02;
					}
					
					if ((PPPU->PPUT_FIR_Cnt  >= 1)&&(PPPU->PPUT_FIR_Cnt  <= 50)&&(0x55 == pOrb->OrbDataIn_OK))
					{
						if ((tmpOrbCmd->OrbCtrlPack[PPPU->PPUT_FIR_Cnt-1].OrbCtrl_Mod == 0x55) ||(tmpOrbCmd->OrbCtrlPack[PPPU->PPUT_FIR_Cnt-1].OrbCtrl_Mod == 0x44))
						{
							pOrb->OrbDataIn_OK = 0x55;	
							PPPU->PPUT_FIR_CntS =PPPU->PPUT_FIR_Cnt;
							
							/*设置下一拍关PPU电源*/
							PPPU->PPU_OrbitCtl_Quit_Err_Flag = POSE_OK;/*正常退出轨控标志使能*/
							PPPU->PPU_OrbitCtl_Quit_Err_Cnt = 0;/*退出轨控后节拍计数清零*/
			
							PPPU->PPU_OrbitCtl_Quit_OK_Flag = POSE_OK;/*正常退出轨控标志使能*/
							PPPU->PPU_OrbitCtl_Quit_OK_Cnt = 0;/*退出轨控后节拍计数清零*/							
							PPPU->PPUOUT_Sta = POSE_NO;/*电推指令开关标志为关*/
							tmpAtt->sCtlPara.ZK_Ctrl_Reserver111 = POSE_NO;	
							//PPU关机指令
							dev_can_write(DEV_NO_CAN0, PPUOff, 8);/*轨控正常退出，电推关机操作，需要5秒后给电推供电*/								
						}
						else
						{
							PPPU->PPUT_FIR_Cnt = 0;
							PPPU->PPUT_FIR_CntS = 0;
							pOrb->OrbDataIn_OK = 0x04;				
						}
					}
				} 
				else
				{
					for (i = 0; i < 50; i++)
					{
						pOrb->OrbCtrlPcak_ReceiveFlg[i]=0x00 ;			
					}
					pOrb->OrbDataIn_OK = 0x01;
					PPPU->PPUT_FIR_Cnt = 0;
				}
				if (POSE_OK == pOrb->OrbDataIn_OK )
				{
					if(pOrb->OrbDataIn_OKCnt<60000)
					{
						pOrb->OrbDataIn_OKCnt++;							
					}
					else
					{
						pOrb->OrbDataIn_OKCnt = 0;
					}
				}
				break;
			}

			//对目标定向数据包上注
			case ATT_CMDMODE_ONLTOTAR:
			{		
				tmpData=(UINT8*)(ATTCLT_DATA4_ADDR);		
				GetTime(SatTime);						
                memcpy(&(tmpiDataLength), tmpData, 4);
                memcpy(&(tmpiDataType), tmpData+ 4, 2);
                memcpy(&(tmpiDataCheck), tmpData+ 6, 2);
                tmpiDataCheck1 =DoGetCheckSum(tmpData + sizeof(sSaveDataHead), tmpiDataLength);						
				pTARC->TARDataIn_OK = POSE_OK;		
				for (i = 0; i < 30; ++i)
				{
					pTARC->TARCtrlPcak_ReceiveFlg[i]= 0x00;
					memset(&tmpTARCCmd->TARCtrlPack[i],0,sizeof(sAttTARCCtlPara_t));
				}
				
				tmpiDataLength1 = 690;
				if ( tmpiDataLength1 != tmpiDataLength)
				{
					pTARC->TARDataIn_OK = 0x02 ;
					return ;
				}				
				if ((0x25==tmpiDataType)&&(tmpiDataCheck == tmpiDataCheck1))
				{
					pTARC->CurTARCtrlPcak_ID = 0;
					pTARC->CurTARCtrlPcak_PreID = 0xFF ;
					for (i = 0; i < 30; i++)
					{   
						memcpy(&(tmpDevNO), tmpData + i * 23 + sizeof(sSaveDataHead) , sizeof(UINT8));
						if ((tmpDevNO>0)&&(tmpDevNO<=30)&&(i +1==tmpDevNO))
						{
							//拷贝数据
							memcpy(&(tmpTARCCmd->TARCtrlPack[tmpDevNO-1].TARCtrlPcak_ID), (UINT8*)(tmpData + i * 23+ sizeof(sSaveDataHead)), sizeof(UINT8));
							tmpTARCCmd->TARCtrlPack[tmpDevNO-1].TARCtrl_JustTime= DoGetInt32From8(tmpData + i * 23 + sizeof(sSaveDataHead) +1);
							tmpTARCCmd->TARCtrlPack[tmpDevNO-1].TARCtrAng[0]= DoGetFloatFrom8(tmpData + i * 23 + sizeof(sSaveDataHead) +5);
							tmpTARCCmd->TARCtrlPack[tmpDevNO-1].TARCtrAng[1]= DoGetFloatFrom8(tmpData + i * 23 + sizeof(sSaveDataHead) +9);
							tmpTARCCmd->TARCtrlPack[tmpDevNO-1].TARCtrAng[2]= DoGetFloatFrom8(tmpData + i * 23 + sizeof(sSaveDataHead) +13);
							tmpTARCCmd->TARCtrlPack[tmpDevNO-1].TARCtrl_StartTime= DoGetInt32From8(tmpData + i * 23 + sizeof(sSaveDataHead) +17);
							tmpTARCCmd->TARCtrlPack[tmpDevNO-1].TARCtrl_TimeLength= DoGetInt16From8(tmpData + i * 23 + sizeof(sSaveDataHead) +21);
							
							tmpTARCCmd->TARCtrlPack[tmpDevNO-1].TARCtrlDateSum=DoGetCheckSum(&(tmpTARCCmd->TARCtrlPack[tmpDevNO-1].TARCtrlPcak_ID), 23);
							pTARC->TARCtrlPcak_ReceiveFlg[tmpDevNO-1]=0x55 ;
						}
					}

					if ((tmpTARCCmd->TARCtrlPack[0].TARCtrl_JustTime > SatTime[0])&&(tmpTARCCmd->TARCtrlPack[0].TARCtrl_StartTime > SatTime[0]))
					{
						for (i = 1; i < 30; i++)
						{
							if (pTARC->TARCtrlPcak_ReceiveFlg[i])
							{
								DETLTime1 = (TYPE_CAL)tmpTARCCmd->TARCtrlPack[i].TARCtrl_JustTime - (TYPE_CAL)tmpTARCCmd->TARCtrlPack[i -1].TARCtrl_JustTime - (TYPE_CAL)tmpTARCCmd->TARCtrlPack[i -1].TARCtrl_TimeLength;
								DETLTime2 = (TYPE_CAL)tmpTARCCmd->TARCtrlPack[i].TARCtrl_StartTime - (TYPE_CAL)tmpTARCCmd->TARCtrlPack[i].TARCtrl_JustTime;
								if ((DETLTime1 < 0.0)|| (DETLTime2 < 0.0))
								{
									pTARC->TARDataIn_OK = 0x01;
									break;
								}
							}
							else
							{
								break;
							}
						}
					}
					else
					{
						pTARC->TARDataIn_OK = 0x01;
					}
				}
				else
				{
					for (i = 0; i < 30; i++)
					{
						pTARC->TARCtrlPcak_ReceiveFlg[i]=0x00 ;
					}
					pTARC->TARDataIn_OK = 0x02 ;
				}
				
				if (POSE_OK == pTARC->TARDataIn_OK )
				{
					if(pTARC->TARDataIn_OKCnt<60000)
					{
						pTARC->TARDataIn_OKCnt++;							
					}
					else
					{
						pTARC->TARDataIn_OKCnt = 0;
					}
				}				
				break;						
			}	

			case ATT_CMDMODE_ORBITCTLREQ:			/* 载荷异步包请求 */
			{
				/* 遥测进程下发异步包 */
				((sYaoCePackege*)GETPKGSTRUCT(TM_PKGNO_YB_32))->iCollectTime = 1;//自动开始组包,组包函数清除标识
				break;
			}
				
			//模式自主切换
			case ATT_CMDMODE_MODECHANG:
			{
				if(0x55 == tmpTaskMngDataRcd->bSHDepart)
				{
					tmpConst->AttCmdFlashPara.WorkModeChangeAuto=POSE_NO;
					tmpAtt->sCtlPara.ZK_Ctrl_Reserver111 = POSE_NO;
					pWMod->ATTFlashSwitch = POSE_OK;
				}
				else
				{
					m_pZKTaskInfo->iCmdRes = ERR_CODE_CMDCODE;	/*指令失败*/
				}
				break;
			}

			case ATT_CMDMODE_NOMODECHANG:
			{
				if(0x55 == tmpTaskMngDataRcd->bSHDepart)
				{
					tmpConst->AttCmdFlashPara.WorkModeChangeAuto=POSE_OK;
					pWMod->ATTFlashSwitch = POSE_OK;
				}
				else
				{
					m_pZKTaskInfo->iCmdRes = ERR_CODE_CMDCODE;	/*指令失败*/
				}
				break;
			}
			//单机间互校验
			case ATT_CMDMODE_AllowCThr:
			{
				if(0x55 == tmpTaskMngDataRcd->bSHDepart)
				{
					tmpConst->Allow_Sensor_CThr=0x55;
				}
				else
				{
					m_pZKTaskInfo->iCmdRes = ERR_CODE_CMDCODE;	/*指令失败*/
				}
				break;
			}
			case ATT_CMDMODE_NOAllowCThr:
			{
				if(0x55 == tmpTaskMngDataRcd->bSHDepart)
				{
					tmpConst->Allow_Sensor_CThr=0x00;
				}
				else
				{
					m_pZKTaskInfo->iCmdRes = ERR_CODE_CMDCODE;	/*指令失败*/
				}
				break;
			}

			//清轨道包
			case ATT_CMDOBITRESET:
			{
				pOrb->CurOrbCtrlPcak_ID = 0;
				pOrb->CurOrbCtrlPcak_PreID =0xFF;
				PPPU->PPUT_FIR_Cnt = 0;
				memset(&tmpAtt->sOrbitInp.OrbCtrlPackCur, 0, sizeof(AttOrbCtrlPara_t));
				memset(&tmpOrbCmd->OrbCtrlPack, 0, 50*sizeof(AttOrbCtrlPara_t));
				ZKModDoSet(ATTMOD_ONLTOEARTH);
				pOrb->OrbDataIn_OK = POSE_NO;
				/*清轨道包，当前拍的关PPU动作*/
				dev_can_write(DEV_NO_CAN0, PPUOff, 8);
				PPPU->PPUOUT_Sta = POSE_NO;/*电推指令开关标志为关*/
				tmpAtt->sCtlPara.ZK_Ctrl_Reserver111 = POSE_NO;	
				/*设置下一拍关PPU电源*/
				PPPU->PPU_OrbitCtl_Quit_Err_Flag = POSE_OK;/*正常退出轨控标志使能*/
				PPPU->PPU_OrbitCtl_Quit_Err_Cnt = 0;/*退出轨控后节拍计数清零*/
					
				PPPU->PPU_OrbitCtl_Quit_OK_Flag = POSE_NO;/*正常退出轨控标志使能*/
				PPPU->PPU_OrbitCtl_Quit_OK_Cnt = 0;/*退出轨控后节拍计数清零*/				
				break;		
			}

			//清目标定向包
			case ATT_CMDATTRESET:
			{
				pTARC->CurTARCtrlPcak_ID=0;
				pTARC->CurTARCtrlPcak_PreID =0xFF;
				memset(&tmpAtt->sTARCInp.TARCtrlPackCur, 0, sizeof(sAttTARCCtlPara_t));
				memset(&tmpTARCCmd->TARCtrlPack, 0, 30*sizeof(sAttTARCCtlPara_t));
				ZKModDoSet(ATTMOD_RATEDMP);
				pTARC->TARDataIn_OK = POSE_NO;
				break;
			}

			//姿态基准丢失
			case ATT_CMDMODE_ATTLOSE:
			{
				if(0x55 == tmpTaskMngDataRcd->bSHDepart)
				{
					tmpConst->AllowAttLoseDiagFlg = 0x55;
				}
				else
				{
					m_pZKTaskInfo->iCmdRes = ERR_CODE_CMDCODE;	/*指令失败*/
				}
				break;
			}
			case ATT_CMDMODE_NOATTLOSE:
			{
				if(0x55 == tmpTaskMngDataRcd->bSHDepart)
				{
					tmpConst->AllowAttLoseDiagFlg = 0;
				}
				else
				{
					m_pZKTaskInfo->iCmdRes = ERR_CODE_CMDCODE;	/*指令失败*/
				}
				break;
			}
		
			//姿态超差
			case ATT_CMDMODE_ATTEx:
			{
				if(0x55 == tmpTaskMngDataRcd->bSHDepart)
				{
					tmpConst->AllowAttExDiagFlg = 0x55;
				}
				else
				{
					m_pZKTaskInfo->iCmdRes = ERR_CODE_CMDCODE;	/*指令失败*/
				}
				break;
			}
			case ATT_CMDMODE_NOATTEx:
			{
				if(0x55 == tmpTaskMngDataRcd->bSHDepart)
				{
					tmpConst->AllowAttExDiagFlg = 0;
				}
				else
				{
					m_pZKTaskInfo->iCmdRes = ERR_CODE_CMDCODE;	/*指令失败*/
				}
				break;
			}

			//姿态不稳定
			case ATT_CMDMODE_AttUnSta:
			{
				if(0x55 == tmpTaskMngDataRcd->bSHDepart)
				{
					tmpConst->AllowAttStaDiagFlg = 0x55;
				}
				else
				{
					m_pZKTaskInfo->iCmdRes = ERR_CODE_CMDCODE;	/*指令失败*/
				}
				break;
			}
			case ATT_CMDMODE_NOAttUnSta:
			{
				if(0x55 == tmpTaskMngDataRcd->bSHDepart)
				{
					tmpConst->AllowAttStaDiagFlg = 0;
				}
				else
				{
					m_pZKTaskInfo->iCmdRes = ERR_CODE_CMDCODE;	/*指令失败*/
				}
				break;
			}
				
			//模式切换相关参数
			case ATT_CMDCODE_MODPARAM:
			{
				tmpWorkModPre = *tmpData;
				tmpWorkMod = *(tmpData + 1);
				tmpWlimit = DoGetFloatFrom8(tmpData+2)*ANG2RADIAN;
				tmpAlimit = DoGetFloatFrom8(tmpData+6) *ANG2RADIAN;
				tmpTimeLmt = DoGetInt16From8(tmpData+10);
				tmpTimeLmt1 = DoGetInt16From8(tmpData+12);
				tmpAngm = DoGetFloatFrom8(tmpData+14);
							
				if((tmpWorkMod & 0x0F) > 0x0B)
				{
					m_pZKTaskInfo->iCmdRes = ERR_CODE_CMDCODE;
					break;
				}
				if(ATTMOD_NOCOLL == tmpWorkModPre)       //1、碰撞规避模式
				{
					tmpConst->judge_time1=tmpTimeLmt;
				}
				else if(ATTMOD_RATEDMP == tmpWorkModPre)
				{
					tmpConst->judge_time2 = tmpTimeLmt;
					tmpConst->RateThr_2T3	=tmpWlimit;
					tmpConst->HWHLThr_2T3 = tmpAngm;
				}
				else if(ATTMOD_WhlTOSUN == tmpWorkModPre)
				{
					tmpConst->judge_time3 = tmpTimeLmt;
					tmpConst->AttCmdFlashPara.judgeWait_time = tmpTimeLmt1;
					tmpConst->AngThr_3TB = tmpAlimit;
					tmpConst->RateThr_3TB = tmpWlimit;
					pWMod->ATTFlashSwitch = POSE_OK;
				}
				else if(ATTMOD_MagTOSUN == tmpWorkModPre)
				{
					tmpConst->judge_time4 = tmpTimeLmt;
					tmpConst->AngThr_3TB = tmpAlimit;
					tmpConst->RateThr_3TB = tmpWlimit;
				}
				else if(ATTMOD_ONLTOEARTH == tmpWorkModPre)
				{
					tmpConst->judge_time5 = tmpTimeLmt;
					tmpConst->AngThr_5T6 = tmpAlimit;
					tmpConst->RateThr_5T6 = tmpWlimit;
				}
				else if(ATTMOD_WHEELTOEARTH == tmpWorkModPre)
				{
					tmpConst->judge_time6 = tmpTimeLmt;
				}
				else if(ATTMOD_ATTAJUSTPRE == tmpWorkModPre)
				{
					tmpConst->judge_time7 = tmpTimeLmt;
				}
				else if(ATTMOD_ORBITCTL == tmpWorkModPre)
				{
					tmpConst->judge_time8 = tmpTimeLmt;
				}
				else if(ATTMOD_ATTAJUST == tmpWorkModPre)
				{
					tmpConst->judge_time9 = tmpTimeLmt;
					tmpConst->AngThr_9TA = tmpAlimit;
					tmpConst->RateThr_9TA = tmpWlimit;
				}
				else if(ATTMOD_ONLTOTAR == tmpWorkModPre)
				{
					tmpConst->judge_timeA = tmpTimeLmt;
				}
				else if(ATTMOD_UNCTL == tmpWorkModPre)
				{
					tmpConst->judge_timeB = tmpTimeLmt;
				}
				else
				{
					m_pZKTaskInfo->iCmdRes = ERR_CODE_CMDCODE; 	/*指令失败*/
				}
				break;
			}
					
			//太敏
			case ATT_CMDCODE_ASS:
			{
                tmpCOMDCHOICE =*(tmpData) ; 
				
				switch (tmpCOMDCHOICE)
				{
					case    0x11 :		
					{
						tmpConst->Ass_MinFour_limt[0] = DoGetFloatFrom8(tmpData+1 +0);						//4片模拟太敏电压阈值
						tmpConst->Ass_MaxFour_limt[0] = DoGetFloatFrom8(tmpData+1 +4);						//4片模拟太敏电压阈值
						break;						
					}
					case	0x22:		
					{
						tmpConst->Ass_MinFour_limt[1] = DoGetFloatFrom8(tmpData+1 +0);						//4片模拟太敏电压阈值
						tmpConst->Ass_MaxFour_limt[1] = DoGetFloatFrom8(tmpData+1 +4);						//4片模拟太敏电压阈值
						break;
					}
					default:
					break;				
				}
				break;	
			}

			//互校验阈值上注
			case ATT_CMDCROSSCHECKTHR:
			{
				tmpConst->SS_SS_CThr = DoGetFloatFrom8(tmpData)*ANG2RADIAN;
				tmpConst->SS_ASS_CCThr = DoGetFloatFrom8(tmpData + 4)*ANG2RADIAN;
				tmpConst->SS_ASS_CThr = DoGetFloatFrom8(tmpData + 8)*ANG2RADIAN;
				tmpConst->AttCmdFlashPara.SS_MAG_CThr = DoGetFloatFrom8(tmpData + 12)*ANG2RADIAN;
				tmpConst->SS_GYRO_CThr = DoGetFloatFrom8(tmpData + 16)*ANG2RADIAN;
				tmpConst->GYRO_GYRO_CThr = DoGetFloatFrom8(tmpData + 20)*ANG2RADIAN;
				tmpConst->MAG_MAG_CThr = DoGetFloatFrom8(tmpData + 24);
				pWMod->ATTFlashSwitch = POSE_OK;
				break;
			}
			
			//单机异常状态
			case ATT_CMDCROSSERR:
			{
				tmpConst->AllowssONOFF[0] = *(tmpData );
				tmpConst->AllowssONOFF[1] = *(tmpData +1);
				tmpConst->AllowssONOFF[2] = *(tmpData +2);
				tmpConst->AllowMagONOFF[0] = *(tmpData+3);
				tmpConst->AllowMagONOFF[1] = *(tmpData +4);
				tmpConst->AllowGyroONOFF[0] = *(tmpData +5);
				tmpConst->AllowGyroONOFF[1] = *(tmpData +6);
				tmpConst->AllowGyroONOFF[2] = *(tmpData +7);
				tmpConst->AllowWhlONOFF[0] = *(tmpData +8);
				tmpConst->AllowWhlONOFF[1] = *(tmpData +9);
				tmpConst->AllowWhlONOFF[2] = *(tmpData +10);
				tmpConst->AllowWhlONOFF[3] = *(tmpData +11);
				tmpConst->AllowPPUONOFF = *(tmpData +12);			
				break;
			}			

			//单机使用状态
			case ATT_CMDCROSSUSE:
			{
				pIMU->SSUseState[0] = *(tmpData);
				pIMU->SSUseState[1] = *(tmpData + 1);
				pIMU->SSUseState[2] = *(tmpData + 2);
				pIMU->AssUseState[0] = *(tmpData + 3);
				pIMU->AssUseState[1] = *(tmpData + 4);
				pIMU->AssUseState[2] = *(tmpData + 5);
				pIMU->AssUseState[3] = *(tmpData + 6);
				pIMU->AssUseState[4] = *(tmpData + 7);
				pIMU->AssUseState[5] = *(tmpData + 8);
				pIMU->MagUseState[0] = *(tmpData + 9);
				pIMU->MagUseState[1] = *(tmpData + 10);
				pIMU->GyroUseState[0] = *(tmpData + 11);
				pIMU->GyroUseState[1] = *(tmpData + 12);
				pIMU->GyroUseState[2] = *(tmpData + 13);
				pIMU->Whl_Use[0] = *(tmpData + 14);
				pIMU->Whl_Use[1] = *(tmpData + 15);
				pIMU->Whl_Use[2] = *(tmpData + 16);
				pIMU->Whl_Use[3] = *(tmpData + 17);
				pIMU->MTUseStatus[0] = *(tmpData + 18);
				pIMU->MTUseStatus[1] = *(tmpData + 19);
				pIMU->MTUseStatus[2] = *(tmpData + 20);
				pIMU->MTUseStatus[3] = *(tmpData + 21);
				pIMU->PPUUseStatus= *(tmpData + 22);
				break;
			}			

			//单机重构状态注入
			case ATT_CMDCROSS:
			{
				//星敏优先级
				if (*(tmpData+0) != *(tmpData +1))
				{
					if (*(tmpData+0) != *(tmpData +2))
					{
						tmpConst->SSUsePrior[0]= *(tmpData) ;
						tmpConst->SSUsePrior[1]= *(tmpData +1) ;
						tmpConst->SSUsePrior[2]= *(tmpData +2) ;						
					}
				}

				//陀螺优先级
				if (*(tmpData+3) != *(tmpData +4))
				{
					if (*(tmpData+3) != *(tmpData +5))
					{
						tmpConst->GyroUsePrior[0]= *(tmpData +3) ;
						tmpConst->GyroUsePrior[1]= *(tmpData +4) ;
						tmpConst->GyroUsePrior[2]= *(tmpData +5) ;
					}
				}
				break;
			}
			case ATT_CMDCREUSE:
			{
				tmpConst->AttCmdFlashPara.Mag_ComRESW[0] = *(tmpData);
				tmpConst->AttCmdFlashPara.Mag_ComRESW[1] = *(tmpData+1);
				tmpConst->AttCmdFlashPara.Mag_ComRESW[2] = *(tmpData+2);
				
				tmpConst->AttCmdFlashPara.Gyro_ComRESW[0] = *(tmpData+3);
				tmpConst->AttCmdFlashPara.Gyro_ComRESW[1] = *(tmpData+4);
				tmpConst->AttCmdFlashPara.Gyro_ComRESW[2] = *(tmpData+5);
				pWMod->ATTFlashSwitch = POSE_OK;
				break;
			}

			//单机故障诊断条件
			case ATT_CMDCROSSDIG:
			{
				tmpConst->ssDiagThr = DoGetInt16From8(tmpData) ;
				tmpConst->MagDiagThr= DoGetInt16From8(tmpData +2) ;
				tmpConst->GyroDiagThr= DoGetInt16From8(tmpData +4) ;
				tmpConst->WhlDiag_ErrThr= DoGetInt16From8(tmpData +6) ;					//判断时间阈值,单位,可上注
				tmpConst->WhlDiag_TimeThr= DoGetInt16From8(tmpData +8) ;				//判断时间阈值,单位,可上注
				tmpConst->WhlTemperDiagThr= DoGetInt16From8(tmpData +10) ;				//判断时间阈值,单位,可上注
				break;
			}

			//PPU故障诊断条件
			case ATT_CMDCPPUDIG:
			{
				tmpConst->PPUTXTimeLimit=DoGetInt16From8(tmpData );					//电推通信故障时间阈值30
				tmpConst->PPUTATimeLimit=DoGetInt16From8(tmpData+2);					//电推过流故障时间阈值60
				tmpConst->AttCmdFlashPara.PPUTALimit=DoGetInt16From8(tmpData+4);						//电推过流故障阈值  1.6
				tmpConst->PPUTVTimeLimit=DoGetInt16From8(tmpData+6);					//电推过压故障时间阈值60
				tmpConst->AttCmdFlashPara.PPUTVLimit=DoGetInt16From8(tmpData+8);						//电推过压故障阈值260
				tmpConst->AttCmdFlashPara.PPUTFireLimit=DoGetInt16From8(tmpData+10);					//电推点火故障阈值300
				tmpConst->PPUTemperTimeLimit=DoGetInt16From8(tmpData+12);				//电推温度故障时间阈值 10
				tmpConst->AttCmdFlashPara.PPUHTemperLimit=DoGetInt16From8(tmpData+14);				//电推温度故障上限阈值   30
				tmpConst->AttCmdFlashPara.PPULTemperLimit=DoGetInt16From8(tmpData+16);				//电推温度故障下限阈值   10
				pWMod->ATTFlashSwitch = POSE_OK;
				break;
			}

			//单机故障诊断时间
			case ATT_CMDCDIGTIME:
			{
                tmpCOMDCHOICE =*(tmpData) ;
                switch (tmpCOMDCHOICE)
                {
	                case    0x11 :
	                {
		                tmpConst->Ss_Delay_CntLimt =DoGetInt16From8(tmpData + 1) ;						//星敏开机异常延迟判断计数
		                tmpConst->Ss_OK_CntLimt= DoGetInt16From8(tmpData+2+ 1) ;						//星敏正常判断计数
		                tmpConst->Ss_Err_CntLimt= DoGetInt16From8(tmpData+4+ 1) ;						//星敏异常判断计数						
		                tmpConst->Ss_ReSet_CntLimt=DoGetInt16From8(tmpData+6+ 1) ;						//星敏重启总次数
		                tmpConst->Ss_ReSetGAP_CntLimt=DoGetInt16From8(tmpData+8+ 1) ;					//星敏重启间隔拍数
		                break;
	                }
	                case    0x22 :
	                {
		                tmpConst->Mag_Delay_CntLimt =DoGetInt16From8(tmpData+ 1) ;						//磁强计开机异常延迟判断计数
		                tmpConst->Mag_OK_CntLimt= DoGetInt16From8(tmpData+2+ 1) ;						//磁强计正常判断计数
		                tmpConst->Mag_Err_CntLimt= DoGetInt16From8(tmpData+4+ 1) ;						//磁强计异常判断计数
		                tmpConst->Mag_ReSet_CntLimt=DoGetInt16From8(tmpData+6+ 1) ;						//磁强计重启总次数
		                tmpConst->Mag_ReSetGAP_CntLimt=DoGetInt16From8(tmpData+8+ 1) ;					//磁强计重启间隔拍数
		                break;
	                }
	                case    0x33 :
	                {
		                tmpConst->Gyro_Delay_CntLimt =DoGetInt16From8(tmpData+ 1) ;						//陀螺开机异常延迟判断计数
		                tmpConst->Gyro_OK_CntLimt= DoGetInt16From8(tmpData+2+ 1) ;						//陀螺正常判断计数
		                tmpConst->Gyro_Err_CntLimt= DoGetInt16From8(tmpData+4+ 1) ;						//陀螺异常判断计数
		                tmpConst->Gyro_ReSet_CntLimt=DoGetInt16From8(tmpData+6+ 1) ;					//陀螺重启总次数
		                tmpConst->Gyro_ReSetGAP_CntLimt=DoGetInt16From8(tmpData+8+ 1) ;					//陀螺重启间隔拍数
		                break;
	                }
	                case    0x44 :
	                {
		                tmpConst->Whl_Delay_CntLimt =DoGetInt16From8(tmpData+ 1) ;						//飞轮开机异常延迟判断计数
		                tmpConst->Whl_OK_CntLimt= DoGetInt16From8(tmpData+2+ 1) ;						//飞轮正常判断计数
		                tmpConst->Whl_Err_CntLimt= DoGetInt16From8(tmpData+4+ 1) ;						//飞轮异常判断计数
		                tmpConst->Whl_ReSet_CntLimt=DoGetInt16From8(tmpData+6+ 1) ;						//飞轮重启总次数
		                tmpConst->Whl_ReSetGAP_CntLimt=DoGetInt16From8(tmpData+8+ 1) ;					//飞轮重启间隔拍数
		                break;
	                }
	                case    0x55 :
	                {
		                tmpConst->PPU_Delay_CntLimt =DoGetInt16From8(tmpData+ 1) ;						//飞轮开机异常延迟判断计数
		                tmpConst->PPU_OK_CntLimt= DoGetInt16From8(tmpData+2+ 1) ;						//飞轮正常判断计数
		                tmpConst->PPU_Err_CntLimt= DoGetInt16From8(tmpData+4+ 1) ;						//飞轮异常判断计数
		                tmpConst->PPU_ReSet_CntLimt=DoGetInt16From8(tmpData+6+ 1) ;						//飞轮重启总次数
		                tmpConst->PPU_ReSetGAP_CntLimt=DoGetInt16From8(tmpData+8+ 1) ;					//飞轮重启间隔拍数
		                break;
	                }
	                default:
	                break;
                }
                break;
			}

			//基准丢失故障诊断条件
			case ATT_CMDCDIGLOSE:
			{
                tmpCOMDCHOICE =*(tmpData) ;               
                switch (tmpCOMDCHOICE)
                {
	                case	ATTMOD_RATEDMP :			
	                {
		                tmpConst->TimeThr_AttLoseDiag[0] = DoGetInt16From8(tmpData+1 );	
		                break;
	                }
					case	ATTMOD_WhlTOSUN:
	                {
		                tmpConst->TimeThr_AttLoseDiag[1] = DoGetInt16From8(tmpData+1 );
		                break;
	                }
	                case    ATTMOD_MagTOSUN :
	                {
		                tmpConst->TimeThr_AttLoseDiag[2] = DoGetInt16From8(tmpData+1 );
		                break;
	                }
	                case    ATTMOD_ONLTOEARTH :
	                {
		                tmpConst->TimeThr_AttLoseDiag[3] = DoGetInt16From8(tmpData+1 );
		                break;
	                }
	                case    ATTMOD_WHEELTOEARTH :
	                {
		                tmpConst->TimeThr_AttLoseDiag[4] = DoGetInt16From8(tmpData+1 );
		                break;
	                }
	                case    ATTMOD_ATTAJUSTPRE :
	                {
		                tmpConst->TimeThr_AttLoseDiag[5] = DoGetInt16From8(tmpData+1 );
		                break;
	                }					
	                case    ATTMOD_ORBITCTL :
	                {
		                tmpConst->TimeThr_AttLoseDiag[6] = DoGetInt16From8(tmpData+1 );
		                break;
	                }
	                case    ATTMOD_ATTAJUST :
	                {
		                tmpConst->TimeThr_AttLoseDiag[7] = DoGetInt16From8(tmpData+1 );
		                break;
	                }
	                case    ATTMOD_ONLTOTAR :
	                {
		                tmpConst->TimeThr_AttLoseDiag[8] = DoGetInt16From8(tmpData+1 );
		                break;
	                }																			                
	                default:
	                break;
                }
				break;
			}
			
			//超差故障诊断条件
			case ATT_CMDCDIGEX:
			{
                tmpCOMDCHOICE =*(tmpData) ;
                switch (tmpCOMDCHOICE)
                {
	                case	ATTMOD_RATEDMP :
	                {
		                tmpConst->TimeThr_AttEx[0] = DoGetInt16From8(tmpData+1 );
		                tmpConst->RateThr_AttEx[0] = DoGetFloatFrom8(tmpData+1 +2) *ANG2RADIAN;
		                tmpConst->AngThr_AttEx[0] = DoGetFloatFrom8(tmpData+1 +6)*ANG2RADIAN;
		                break;
	                }
	                case	ATTMOD_WhlTOSUN:
	                {
		                tmpConst->TimeThr_AttEx[1] = DoGetInt16From8(tmpData+1 );
		                tmpConst->RateThr_AttEx[1] = DoGetFloatFrom8(tmpData+1 +2)*ANG2RADIAN;
		                tmpConst->AngThr_AttEx[1] = DoGetFloatFrom8(tmpData+1 +6)*ANG2RADIAN;
		                break;
	                }
	                case    ATTMOD_MagTOSUN :
	                {
		                tmpConst->TimeThr_AttEx[2] = DoGetInt16From8(tmpData+1 );
		                tmpConst->RateThr_AttEx[2] = DoGetFloatFrom8(tmpData+1 +2)*ANG2RADIAN;
		                tmpConst->AngThr_AttEx[2] = DoGetFloatFrom8(tmpData+1 +6)*ANG2RADIAN;
		                break;
	                }

	                case    ATTMOD_ONLTOEARTH :
	                {
		                tmpConst->TimeThr_AttEx[3] = DoGetInt16From8(tmpData+1 );
		                tmpConst->RateThr_AttEx[3] = DoGetFloatFrom8(tmpData+1 +2)*ANG2RADIAN;
		                tmpConst->AngThr_AttEx[3] = DoGetFloatFrom8(tmpData+1 +6)*ANG2RADIAN;
		                break;
	                }

	                case    ATTMOD_WHEELTOEARTH :
	                {
		                tmpConst->TimeThr_AttEx[4] = DoGetInt16From8(tmpData+1 );
		                tmpConst->RateThr_AttEx[4] = DoGetFloatFrom8(tmpData+1 +2)*ANG2RADIAN;
		                tmpConst->AngThr_AttEx[4] = DoGetFloatFrom8(tmpData+1 +6)*ANG2RADIAN;
						tmpConst->YawCntLimit = DoGetInt16From8(tmpData+1+10 );
		                break;
	                }
	                
	                case    ATTMOD_ATTAJUSTPRE :
					{
		                tmpConst->TimeThr_AttEx[5] = DoGetInt16From8(tmpData+1 );
		                tmpConst->RateThr_AttEx[5] = DoGetFloatFrom8(tmpData+1 +2)*ANG2RADIAN;
		                tmpConst->AngThr_AttEx[5] = DoGetFloatFrom8(tmpData+1 +6)*ANG2RADIAN;
		                break;
	                }

	                case    ATTMOD_ORBITCTL :
	                {
		                tmpConst->TimeThr_AttEx[6] = DoGetInt16From8(tmpData+1 );
		                tmpConst->RateThr_AttEx[6] = DoGetFloatFrom8(tmpData+1 +2)*ANG2RADIAN;
		                tmpConst->AngThr_AttEx[6] = DoGetFloatFrom8(tmpData+1 +6)*ANG2RADIAN;
		                break;
	                }

	                case    ATTMOD_ATTAJUST :
	                {
		                tmpConst->TimeThr_AttEx[7] = DoGetInt16From8(tmpData+1 );
		                tmpConst->RateThr_AttEx[7] = DoGetFloatFrom8(tmpData+1 +2)*ANG2RADIAN;
		                tmpConst->AngThr_AttEx[7] = DoGetFloatFrom8(tmpData+1 +6)*ANG2RADIAN;
		                break;
	                }

	                case    ATTMOD_ONLTOTAR :
	                {
		                tmpConst->TimeThr_AttEx[8] = DoGetInt16From8(tmpData+1 );
		                tmpConst->RateThr_AttEx[8] = DoGetFloatFrom8(tmpData+1 +2)*ANG2RADIAN;
		                tmpConst->AngThr_AttEx[8] = DoGetFloatFrom8(tmpData+1 +6)*ANG2RADIAN;
		                break;
	                }
	                default:
	                break;
                }
				break;
			}

			//姿态不稳定故障诊断条件
			case ATT_CMDCDIGNOSTATE:
			{
                tmpCOMDCHOICE =*(tmpData) ;
                switch (tmpCOMDCHOICE)
                {
	                case    ATTMOD_RATEDMP :
	                {
		                tmpConst->TimeThr_AttUnSta[0] = DoGetInt16From8(tmpData+1 );
						tmpConst->TimeMod_AttUnSta[0] = DoGetInt16From8(tmpData+1 +2 );
		                tmpConst->RateThr_AttUnSta[0] = DoGetFloatFrom8(tmpData+1 +2 +2)*ANG2RADIAN;
		                tmpConst->AngThr_AttUnSta[0] = DoGetFloatFrom8(tmpData+1 +4 +4)*ANG2RADIAN;
		                break;
	                }
	                case ATTMOD_WhlTOSUN:
	                {
		                tmpConst->TimeThr_AttUnSta[1] = DoGetInt16From8(tmpData+1 );
		                tmpConst->TimeMod_AttUnSta[1] = DoGetInt16From8(tmpData+1 +2 );
		                tmpConst->RateThr_AttUnSta[1] = DoGetFloatFrom8(tmpData+1 +2 +2)*ANG2RADIAN;
		                tmpConst->AngThr_AttUnSta[1] = DoGetFloatFrom8(tmpData+1 +4 +4)*ANG2RADIAN;
		                break;
	                }
	                case    ATTMOD_MagTOSUN :
	                {
		                tmpConst->TimeThr_AttUnSta[2] = DoGetInt16From8(tmpData+1 );
		                tmpConst->TimeMod_AttUnSta[2] = DoGetInt16From8(tmpData+1 +2 );
		                tmpConst->RateThr_AttUnSta[2] = DoGetFloatFrom8(tmpData+1 +2 +2)*ANG2RADIAN;
		                tmpConst->AngThr_AttUnSta[2] = DoGetFloatFrom8(tmpData+1 +4 +4)*ANG2RADIAN;
		                break;
	                }

	                case    ATTMOD_ONLTOEARTH :
	                {
		                tmpConst->TimeThr_AttUnSta[3] = DoGetInt16From8(tmpData+1 );
		                tmpConst->TimeMod_AttUnSta[3] = DoGetInt16From8(tmpData+1 +2 );
		                tmpConst->RateThr_AttUnSta[3] = DoGetFloatFrom8(tmpData+1 +2 +2)*ANG2RADIAN;
		                tmpConst->AngThr_AttUnSta[3] = DoGetFloatFrom8(tmpData+1 +4 +4)*ANG2RADIAN;
		                break;
	                }
               
	                case    ATTMOD_ATTAJUSTPRE :
	                {
		                tmpConst->TimeThr_AttUnSta[4] = DoGetInt16From8(tmpData+1 );
		                tmpConst->TimeMod_AttUnSta[4] = DoGetInt16From8(tmpData+1 +2 );
		                tmpConst->RateThr_AttUnSta[4] = DoGetFloatFrom8(tmpData+1 +2 +2)*ANG2RADIAN;
		                tmpConst->AngThr_AttUnSta[4] = DoGetFloatFrom8(tmpData+1 +4+4)*ANG2RADIAN;
		                break;
	                }
	                case    ATTMOD_ATTAJUST :
	                {
		                tmpConst->TimeThr_AttUnSta[5] = DoGetInt16From8(tmpData+1 );
		                tmpConst->TimeMod_AttUnSta[5] = DoGetInt16From8(tmpData+1 +2 );
		                tmpConst->RateThr_AttUnSta[5] = DoGetFloatFrom8(tmpData+1 +2 +2)*ANG2RADIAN;
		                tmpConst->AngThr_AttUnSta[5] = DoGetFloatFrom8(tmpData+1 +4 +4)*ANG2RADIAN;
		                break;
	                }
	                default:
	                break;
                }
                break;
			}
			
			//配平轮转速力矩阈值
			case ATT_CMDWHLSLIMT:
			{
				tmpConst->WheelD_NomSpeed = DoGetFloatFrom8(tmpData);   //rpm
				tmpConst->WheelD_SpeedErrThr =  DoGetFloatFrom8(tmpData+4);
				tmpConst->WheelD_Default =  DoGetFloatFrom8(tmpData+8);
				tmpConst->WheelD_AllDefault =  DoGetFloatFrom8(tmpData+12);
				break;
			}	
						
			/**********************************安装矩阵*********************************/
			//星敏安装矩阵注入
			case ATT_CMDCODE_SSMAT:
			{
                tmpCOMDCHOICE =*(tmpData) ;
                switch (tmpCOMDCHOICE)
				{
					case    0x11 :
					{
						for(i=0; i<3; i++)
						{
							for (k=0; k<3; k++)
							{
								tmpConst->AttCmdFlashPara.M_SSA[i][k] = DoGetFloatFrom8(tmpData+i*12+k*4 + 1);
							}
						}
						break;
					}					
					case    0x22 :
					{
						for(i=0; i<3; i++)
						{
							for (k=0; k<3; k++)
							{
								tmpConst->AttCmdFlashPara.M_SSB[i][k] = DoGetFloatFrom8(tmpData+i*12+k*4 + 1);
							}
						}
						break;
					}
					case    0x44 :
					{
						for(i=0; i<3; i++)
						{
							for (k=0; k<3; k++)
							{
								tmpConst->AttCmdFlashPara.M_SSC[i][k] = DoGetFloatFrom8(tmpData+i*12+k*4 + 1);
							}
						}
						break;
					}
	                default:
	                break;					
				}
				pWMod->ATTFlashSwitch = POSE_OK;
				break;
			}
			
			//太敏安装矩阵注入
			case ATT_CMDCODE_ASSMAT:
			{
				tmpDevNO = *tmpData;   //太敏选择
				if(0x11 == tmpDevNO)
				{
					for(i=0; i<3; i++)
					{
						for (k=0; k<3; k++)
						{
							tmpConst->AttCmdFlashPara.M_aSSA[i][k] =  DoGetFloatFrom8(tmpData+i*12+k*4+1);
						}
					}
				}
				else if(0x22 == tmpDevNO)
				{
					for(i=0; i<3; i++)
					{
						for (k=0; k<3; k++)
						{
							tmpConst->AttCmdFlashPara.M_aSSB[i][k] =  DoGetFloatFrom8(tmpData+i*12+k*4+1);
						}
					}
				}
				else if(0x33 == tmpDevNO)
				{
					for(i=0; i<3; i++)
					{
						for (k=0; k<3; k++)
						{
							tmpConst->AttCmdFlashPara.M_aSSC[i][k] =  DoGetFloatFrom8(tmpData+i*12+k*4+1);
						}
					}
				}
				else if(0x44 == tmpDevNO)
				{
					for(i=0; i<3; i++)
					{
						for (k=0; k<3; k++)
						{
							tmpConst->AttCmdFlashPara.M_aSSD[i][k] =  DoGetFloatFrom8(tmpData+i*12+k*4+1);
						}
					}
				}
				else if(0x55 == tmpDevNO)
				{
					for(i=0; i<3; i++)
					{
						for (k=0; k<3; k++)
						{
							tmpConst->AttCmdFlashPara.M_aSSE[i][k] =  DoGetFloatFrom8(tmpData+i*12+k*4+1);
						}
					}
				}
				else if(0x66 == tmpDevNO)
				{
					for(i=0; i<3; i++)
					{
						for (k=0; k<3; k++)
						{
							tmpConst->AttCmdFlashPara.M_aSSF[i][k] =  DoGetFloatFrom8(tmpData+i*12+k*4+1);
						}
					}
				}
				else
				{
					m_pZKTaskInfo->iCmdRes = ERR_CODE_CMDCODE;
				}
				pWMod->ATTFlashSwitch = POSE_OK;
				break;
			}

			//磁强计安装矩阵注入
			case ATT_CMDCODE_MAGMAT:
			{
                tmpCOMDCHOICE =*(tmpData) ;
                switch (tmpCOMDCHOICE)
                {
	                case    0x11 :
	                {
						for(i=0; i<3; i++)
						{
							for(k=0; k<3; k++)
							{
								tmpConst->AttCmdFlashPara.M_MAG[0][i][k] =  DoGetFloatFrom8(tmpData+i*12+k*4 +1);
							}
						}
						break;
	                }
	                case    0x22 :
	                {
						for(i=0; i<3; i++)
						{
							for(k=0; k<3; k++)
							{
								tmpConst->AttCmdFlashPara.M_MAG[1][i][k] =  DoGetFloatFrom8(tmpData+i*12+k*4 +1);
							}
						}
						break;
	                }
	                default:
	                break;
                }
				pWMod->ATTFlashSwitch = POSE_OK;
                break;
			}

			//陀螺安装矩阵注入
			case ATT_CMDCODE_GyroMAT:
			{
                tmpCOMDCHOICE =*(tmpData) ;
                switch (tmpCOMDCHOICE)
                {
	                case    0x11 :
	                {
						for(i=0; i<3; i++)
						{
							for (k=0; k<3; k++)
							{
								tmpConst->AttCmdFlashPara.M_GYRO[0][i][k] = DoGetFloatFrom8(tmpData+i*12+k*4 +1);
							}
						}
						break;
	                }
	                case    0x22 :
	                {
						for(i=0; i<3; i++)
						{
							for (k=0; k<3; k++)
							{
								tmpConst->AttCmdFlashPara.M_GYRO[1][i][k] = DoGetFloatFrom8(tmpData+i*12+k*4 +1);
							}
						}
						break;
	                }
	                case    0x44 :
	                {
						for(i=0; i<3; i++)
						{
							for (k=0; k<3; k++)
							{
								tmpConst->AttCmdFlashPara.M_GYRO[2][i][k] = DoGetFloatFrom8(tmpData+i*12+k*4 +1);
							}
						}
						break;
	                }
	                default:
	                break;
                }
				pWMod->ATTFlashSwitch = POSE_OK;
                break;
			}

			//反作用轮安装矩阵注入
			case ATT_CMDCODE_WHLMAT:
			{
                tmpCOMDCHOICE =*(tmpData) ;
                switch (tmpCOMDCHOICE)
                {
	                case    0x11 :
	                {
						for(i=0; i<3; i++)
						{
							tmpConst->AttCmdFlashPara.M_Wheel[i][0] = DoGetFloatFrom8(tmpData+i*4 +1);
						}
						break;
	                }
	                case    0x22 :
	                {
						for(i=0; i<3; i++)
						{
							tmpConst->AttCmdFlashPara.M_Wheel[i][1] = DoGetFloatFrom8(tmpData+i*4 +1);
						}
						break;
	                }
	                case    0x44 :
	                {
						for(i=0; i<3; i++)
						{
							tmpConst->AttCmdFlashPara.M_Wheel[i][2] = DoGetFloatFrom8(tmpData+i*4 +1);
						}
						break;
	                }
					
	                case    0x88 :
	                {
						for(i=0; i<3; i++)
						{
							tmpConst->AttCmdFlashPara.M_Wheel[i][3] = DoGetFloatFrom8(tmpData+i*4 +1);
						}
						break;
	                }					
	                default:
	                break;
				}
				pWMod->ATTFlashSwitch = POSE_OK;
				break;
			}

			//磁力矩器安装矩阵注入
			case ATT_CMDCODE_MTMAT:
			{
                tmpCOMDCHOICE =*(tmpData) ;
                switch (tmpCOMDCHOICE)
                {
	                case    0x11 :
	                {
		                for(i=0; i<3; i++)
		                {
			                tmpConst->AttCmdFlashPara.M_MAGCtrl[i][0] =  DoGetFloatFrom8(tmpData+i*4 +1);
		                }
		                break;
	                }
	                case    0x22 :
	                {
		                for(i=0; i<4; i++)
		                {
							tmpConst->AttCmdFlashPara.M_MAGCtrl[i][1] =  DoGetFloatFrom8(tmpData+i*4 +1);
		                }
		                break;
	                }
	                case    0x44 :
	                {
		                for(i=0; i<4; i++)
		                {
			                tmpConst->AttCmdFlashPara.M_MAGCtrl[i][2] =  DoGetFloatFrom8(tmpData+i*4 +1);
		                }
		                break;
	                }
	                
	                case    0x88 :
	                {
		                for(i=0; i<4; i++)
		                {
			                tmpConst->AttCmdFlashPara.M_MAGCtrl[i][3] =  DoGetFloatFrom8(tmpData+i*4 +1);
		                }
		                break;
	                }
	                default:
	                break;
                }
				pWMod->ATTFlashSwitch = POSE_OK;
                break;
			}

			//磁阻尼控制器注入
			case ATT_CMDCODE_DMPPARA:
			{
				tmpConst->Mag_Bb_CtrlMax = DoGetFloatFrom8(tmpData);
				tmpConst->Mag_DampBdotMin = DoGetFloatFrom8(tmpData+4);
				tmpConst->MTCtrlTIME= DoGetInt16From8(tmpData+ 8);	
				break;
			}
			
			//磁控对日控制器参数注入
			case ATT_CMDCODE_TOSUNPARA:
			{
                tmpCOMDCHOICE =*(tmpData) ;
                switch (tmpCOMDCHOICE)
				{
					case    0x55 :
					{
						for (i = 0; i < 3; i++)
						{
							tmpConst->Mag_Kp[i] = DoGetFloatFrom8(tmpData+i*4 +1);  
						}
						for (i = 0; i < 3; i++)
						{
							tmpConst->Mag_Kd[i] = DoGetFloatFrom8(tmpData+i*4+12+1);
						}
						tmpConst->Mag_WTOSUN=DoGetFloatFrom8(tmpData + 12 + 12 +1) *ANG2RADIAN ;	
						break;					
					}

					case    0xAA :
					{
						for (i = 0; i < 3; i++)
						{
							tmpConst->Mag_KpFBZK[i] = DoGetFloatFrom8(tmpData+i*4+1); 
						}
						for (i = 0; i < 3; i++)
						{
							tmpConst->Mag_KdFBZK[i] = DoGetFloatFrom8(tmpData+i*4+ 12+1);
						}
						tmpConst->Mag_FBZKWTOSUN=DoGetFloatFrom8(tmpData + 12 + 12 +1) *ANG2RADIAN ;						
						break;				
					}
					default:
					break;	
				}
				tmpConst->Mag_ATTTOSUN=DoGetFloatFrom8(tmpData + 12 + 12 + 4+1) *ANG2RADIAN ;	
				break;
			}

			//磁卸载控制器参数注入
			case ATT_CMDCODE_MTCTRLPARA:
			{
				tmpConst->k1_dump		= DoGetFloatFrom8(tmpData);
				tmpConst->k2_dump		= DoGetFloatFrom8(tmpData+4);
				tmpConst->MTAtt_dump	= DoGetFloatFrom8(tmpData+8) *ANG2RADIAN ;
				tmpConst->ku_dump		= DoGetFloatFrom8(tmpData+12);
				break;
			}

			//飞轮PD控制器参数注入
			case ATT_CMDCODE_PDCTRLPARA:
			{
				tmpWorkMod =*tmpData;
				if (tmpWorkMod == 0xAA)
				{
					for(i=0; i<3; i++)
					{
						tmpConst->AttCmdFlashPara.kp_ToSun_PD[i] = DoGetFloatFrom8(tmpData+1+i*4);
						tmpConst->AttCmdFlashPara.kd_ToSun_PD[i]  = DoGetFloatFrom8(tmpData+13+i*4);
					}
					tmpConst->AttCmdFlashPara.w0max_PD = DoGetFloatFrom8(tmpData+13+12) * ANG2RADIAN;
					tmpConst->AttCmdFlashPara.PD_Ts = DoGetFloatFrom8(tmpData+13+12 +4);
				}
				else if (tmpWorkMod == 0x55)
				{
					for(i=0; i<3; i++)
					{
						tmpConst->kp_NoToSun_PD[i] = DoGetFloatFrom8(tmpData+1+i*4);
						tmpConst->kd_NoToSun_PD[i]  = DoGetFloatFrom8(tmpData+13+i*4);
					}
					tmpConst->w0max_NoPD = DoGetFloatFrom8(tmpData+13+12) * ANG2RADIAN;
					tmpConst->PDNo_Ts = DoGetFloatFrom8(tmpData+13+12 +4);
				}		

				pWMod->ATTFlashSwitch = POSE_OK;
				break;
			}

			//PID控制器参数注入
			case ATT_CMDCODE_PIDCTRLPARA:
			{
				//tmpData = tmpCmd + tmpOffset;
				tmpWorkMod =*tmpData;
				if (tmpWorkMod == 0xAA)
				{
					for(i=0; i<3; i++)
					{
						tmpConst->AttCmdFlashPara.kp_PID[i]	= DoGetFloatFrom8(tmpData+i*4 +1);
						tmpConst->AttCmdFlashPara.ki_PID[i]	= DoGetFloatFrom8(tmpData+12+i*4+1);
						tmpConst->AttCmdFlashPara.kd_PID[i]	= DoGetFloatFrom8(tmpData+24+i*4+1);
					}
					tmpConst->AttCmdFlashPara.w0max_PID = DoGetFloatFrom8(tmpData+36+1) * ANG2RADIAN;
					tmpConst->AttCmdFlashPara.PID_Ts = DoGetFloatFrom8(tmpData+40+1);
					pWMod->ATTFlashSwitch = POSE_OK;
				}
				else if (tmpWorkMod == 0x55)
				{
					for(i=0; i<3; i++)
					{
						tmpConst->kp_NoPID[i]	= DoGetFloatFrom8(tmpData+i*4 +1);
						tmpConst->ki_NoPID[i]	= DoGetFloatFrom8(tmpData+12+i*4+1);
						tmpConst->kd_NoPID[i]	= DoGetFloatFrom8(tmpData+24+i*4+1);
					}
					tmpConst->w0max_NoPID = DoGetFloatFrom8(tmpData+36+1) * ANG2RADIAN;	
					tmpConst->PIDNo_Ts = DoGetFloatFrom8(tmpData+40+1);	
				}


				break;
			}

			//陀螺零偏注入
			case ATT_CMDCODE_GyroBIAS:
			{
				tmpWorkMod =*tmpData;
				if (0x11==tmpWorkMod)
				{
					for (k = 0; k < 3; k++)
					{
						tmpConst->AttCmdFlashPara.Gyro_Comd_Bias[0][k] =DoGetFloatFrom8(tmpData+k*4 +1) * ANG2RADIAN;     //陀螺零偏
					}
				} 
				else if (0x22==tmpWorkMod)
				{
					for (k = 0; k < 3; k++)
					{
						tmpConst->AttCmdFlashPara.Gyro_Comd_Bias[1][k] =DoGetFloatFrom8(tmpData+k*4 +1) * ANG2RADIAN;     //陀螺零偏
					}
				}
				else if (0x44==tmpWorkMod)
				{
					for (k = 0; k < 3; k++)
					{
						tmpConst->AttCmdFlashPara.Gyro_Comd_Bias[2][k] =DoGetFloatFrom8(tmpData+k*4 +1) * ANG2RADIAN;     //陀螺零偏
					}
				}
				pWMod->ATTFlashSwitch = POSE_OK;
				break;
			}

			//陀螺标度因数注入
			case ATT_CMDCODE_GyroPH:
			{

				tmpWorkMod =*tmpData;
				if (0x11==tmpWorkMod)
				{
					for (i = 0; i < 3; i++)
					{
						for (j = 0; j< 3; j++)
						{
							tmpConst->AttCmdFlashPara.Gyro_Comd_K[0][i][j] =DoGetFloatFrom8(tmpData+i*12+j*4+1);     //陀螺标度因数
						}
					}
				}
				else if (0x22==tmpWorkMod)
				{
					for (i = 0; i < 3; i++)
					{
						for (j = 0; j< 3; j++)
						{
							tmpConst->AttCmdFlashPara.Gyro_Comd_K[1][i][j] =DoGetFloatFrom8(tmpData+i*12+j*4+1);     //陀螺标度因数
						}
					}
				}
				else if (0x44==tmpWorkMod)
				{
					for (i = 0; i < 3; i++)
					{
						for (j = 0; j< 3; j++)
						{
							tmpConst->AttCmdFlashPara.Gyro_Comd_K[2][i][j] =DoGetFloatFrom8(tmpData+i*12+j*4+1);     //陀螺标度因数
						}
					}
				}
				pWMod->ATTFlashSwitch = POSE_OK;
				break;
			}
	
			//卫星进出影判断值参数注入
			case ATT_CMDCODE_BetaAng:
			{
				tmpConst->BetaAngLimit = DoGetFloatFrom8(tmpData) *ANG2RADIAN ;
				break;
			}
			
			//飞轮ID选择参数注入
			case ATT_CMDCODE_WhlID:
			{
				memset(tmpWhlCmd,0x00,5*sizeof(UINT8));
				
				tmpWorkMod =*tmpData;
				if (0x11==tmpWorkMod)
				{
					tmpConst->Whl_ID[0] =*(tmpData +1);
					tmpWhlCmd[0] = 0x00;
					tmpWhlCmd[1] = 0x03;
					tmpWhlCmd[2] = tmpWorkMod ;
					tmpWhlCmd[3] = tmpWorkMod ;
					tmpWhlCmd[4] =tmpConst->Whl_ID[0];
				}
				else if (0x22==tmpWorkMod)
				{
					tmpConst->Whl_ID[1] =*(tmpData +1);
					tmpWhlCmd[0] = 0x00;
					tmpWhlCmd[1] = 0x03;
					tmpWhlCmd[2] = tmpWorkMod ;
					tmpWhlCmd[3] = tmpWorkMod ;
					tmpWhlCmd[4] =tmpConst->Whl_ID[1];
				}
				else if (0x33==tmpWorkMod)
				{
					tmpConst->Whl_ID[2] =*(tmpData +1);
					tmpWhlCmd[0] = 0x00;
					tmpWhlCmd[1] = 0x03;
					tmpWhlCmd[2] = tmpWorkMod ;
					tmpWhlCmd[3] = tmpWorkMod ;
					tmpWhlCmd[4] =tmpConst->Whl_ID[2];
				}
				else if (0x44==tmpWorkMod)
				{
					tmpConst->Whl_ID[3] =*(tmpData +1);
					tmpWhlCmd[0] = 0x00;
					tmpWhlCmd[1] = 0x03;
					tmpWhlCmd[2] = tmpWorkMod ;
					tmpWhlCmd[3] = tmpWorkMod ;
					tmpWhlCmd[4] =tmpConst->Whl_ID[3];
				}			
				BlockRingAdd(&tmpCollectInfo->sCmdBuffer,tmpWhlCmd,TRUE);
				break;					
			}
			
			//磁力矩器分配-磁矩限值
			case ATT_CMDCODE_MTCTRL:
			{
				tmpConst->MTOutXYZLimit[0] = DoGetFloatFrom8(tmpData);
				tmpConst->MTOutXYZLimit[1] = DoGetFloatFrom8(tmpData +4);
				tmpConst->MTOutXYZLimit[2] = DoGetFloatFrom8(tmpData +8);
				tmpConst->MTOutXYZLimit[3] = DoGetFloatFrom8(tmpData +12);
				break;
			}			
			
			//磁强计标定系数注入
			case ATT_CMDCODE_MTBD:
			{
				memset(&tmpCOMDCHOICE,0x00,sizeof(UINT8));
				tmpCOMDCHOICE =*tmpData;
				if (0x11==tmpCOMDCHOICE)
				{
					for (i = 0; i< 3; i++)
					{
						tmpConst->AttCmdFlashPara.MAG_LK[0][i]=DoGetFloatFrom8(tmpData+i*4+1);
						tmpConst->AttCmdFlashPara.MAG_LB[0][i]=DoGetFloatFrom8(tmpData+12+i*4+1);
					}				
				}
				else if (0x22==tmpCOMDCHOICE)
				{
					for (i = 0; i< 3; i++)
					{
						tmpConst->AttCmdFlashPara.MAG_LK[1][i]=DoGetFloatFrom8(tmpData+i*4+1);
						tmpConst->AttCmdFlashPara.MAG_LB[1][i]=DoGetFloatFrom8(tmpData+12+i*4+1);
					}
				}
				pWMod->ATTFlashSwitch = POSE_OK;
				break;		
			}

			//加速度
			case ATT_CMDMODE_PPUAB:
			{
				for (i = 0; i < 3; i++)
				{
					tmpConst->AccThru_Up[i] = DoGetFloatFrom8(tmpData+i*4) * 0.001f;
				}
				break;
			}
			
			case ATT_CMDCODE_PPUBD:
			{
				tmpConst->AttCmdFlashPara.PPUPVK = DoGetFloatFrom8(tmpData);
				tmpConst->AttCmdFlashPara.PPUPVB = DoGetFloatFrom8(tmpData +4);
				tmpConst->AttCmdFlashPara.PPUPAK = DoGetFloatFrom8(tmpData +8);
				tmpConst->AttCmdFlashPara.PPUPAB = DoGetFloatFrom8(tmpData +12);
				pWMod->ATTFlashSwitch = POSE_OK;
				break;	
			}
					
			//姿态确定
			case ATT_CMDCODE_GyroINTTLimt:
			{
				tmpConst->GyroINT_TLimt	= DoGetInt16From8(tmpData);
				break;
			}
						
			//安全模式PPU单机使用状态
			case ATT_CMDCODE_SafePPU:
			{
				pIMU->PPUSafeStatus= *(tmpData);
				break;
			}

			//安全模式PPU单机使用状态
			case ATT_CMDCODE_WHLCENT:
			{
				tmpConst->Whl_HCent[0] = DoGetFloatFrom8(tmpData);
				tmpConst->Whl_HCent[1] = DoGetFloatFrom8(tmpData +4);
				tmpConst->Whl_HCent[2] = DoGetFloatFrom8(tmpData +8);
				tmpConst->Whl_HCent[3] = DoGetFloatFrom8(tmpData +12);
				break;
			}	
						
			default:
			{
				m_pZKTaskInfo->iCmdRes = ERR_CODE_CMDCODE;
				break;
			}					
		}
	}
}



/***********************************************
说明：姿控指令处理
***********************************************/
void ZKMINICmdResolve(UINT8 *tmpCmd)
{
#ifdef  MINMODULE_TYPE
	UINT8		i= 0x00;
	UINT8		j= 0x00;
	UINT8		k= 0x00;
	//UINT8		tmpCmd[MOD_REQ_MAXLEN]= {0x00};
	//UINT8		tmpWhlCmd[MOD_REQ_MAXLEN]= {0x00};
	UINT16		tmpCmdCode = 0;			            //指令码
	UINT8		tmpOffset = 0x02;					//指令码偏移
	UINT8		*tmpData= 0x00;
	UINT8		tmpDevNO = 0x00;

	UINT32		tmpiDataLength= 0x00;					/*数据长度*/
	UINT16		tmpiDataType =0;					/*数据类型*/
	UINT16		tmpiDataCheck=0;					/*数据校验和*/
	UINT16		tmpiDataCheck1=0;					/*数据校验和*/

	TYPE_CAL	tmpWlimit=0.0;
	TYPE_CAL	tmpAlimit=0.0;
	TYPE_CAL	tmpAngm=0.0;
	UINT16		tmpTimeLmt=0;
	UINT16      tmpTimeLmt1=0;
	UINT8		tmpWorkMod= 0x00;
	UINT8		tmpWorkModPre= 0x00;
	UINT8		tmpCOMDCHOICE= 0x00;

	sTaskMngDataRecord * tmpTaskMngDataRcd = NULL;
	sAttPriData *tmpAtt= NULL;
	AttCtrlConst_t *tmpConst= NULL;
	sAttOrbitCtlData_t *tmpOrbCmd= NULL;
	sAttTARCCtlData_t *tmpTARCCmd= NULL;
	sAttOrbitCtlInfo_t *pOrb= NULL;
	sAttTARCCtlInfo_t *pTARC= NULL;
	sAttModPara_t *pWMod= NULL;
	sAttErrCtlPara_t *pREcheck= NULL;
	AttIMPTPara_t *pIMU= NULL;
	tmpAtt=(sAttPriData *)ATTCLT_DATA1_ADDR;
	tmpConst=(AttCtrlConst_t *)ATTCLT_DATA2_ADDR;
	tmpOrbCmd=(sAttOrbitCtlData_t *)ATTCLT_DATA3_ADDR;
	tmpTARCCmd=(sAttTARCCtlData_t *)ATTCLT_DATA6_ADDR;
	tmpTaskMngDataRcd = (sTaskMngDataRecord *)ST_TASKMNG_ADDR;	
	if((NULL == tmpAtt) || (NULL ==tmpConst) || (NULL ==tmpOrbCmd) || (NULL ==tmpTARCCmd)|| (NULL ==tmpTaskMngDataRcd))
	{
		return ;
	}
	pOrb=&tmpAtt->sOrbitInp;
	pTARC=&tmpAtt->sTARCInp;
	pREcheck=&tmpAtt->sErrCtlPara;
	pIMU=&tmpAtt->sIMPTPara;
	pWMod=&tmpAtt->sModePara;
	
	/*处理每个命令*/
	tmpCmdCode = DoGetInt16From8(tmpCmd + tmpOffset);
	m_pZKTaskInfo->iCmdLast = tmpCmdCode;
	m_pZKTaskInfo->iCmdRes = ERR_CODE_NOERR;
	m_pZKTaskInfo->iCmdCount++;
	//获取注数缓存地址
	tmpData=(UINT8*)(tmpCmd + tmpOffset +2);
			
	switch(tmpCmdCode)
	{
		/**********************************模式控制指令*********************************/
		//速率阻尼 0X22
		case ATT_CMDMODE_MODSUNCAP:
		{
			//tmpConst->WorkModeUp = ATTMOD_RATEDMP;
			//tmpConst->WorkModeChange=0x55;
			/*设置工作模式 速率阻尼*/
			ZKModDoSet(ATTMOD_RATEDMP);
			break;
		}

		//磁控对日定向0X44
		case ATT_CMDMODE_MagTOSUN:
		{
			//tmpConst->WorkModeUp = ATTMOD_MagTOSUN;
			//tmpConst->WorkModeChange=0x55;
			/*设置工作模式 速率阻尼*/
			ZKModDoSet(ATTMOD_MagTOSUN);
			break;
		}
		//模式自主切换
		case ATT_CMDMODE_MODECHANG:
		{
			tmpConst->AttCmdFlashPara.WorkModeChangeAuto=POSE_NO;
			pWMod->ATTFlashSwitch = POSE_OK;
			break;
		}

		case ATT_CMDMODE_NOMODECHANG:
		{
			tmpConst->AttCmdFlashPara.WorkModeChangeAuto=POSE_OK;
			pWMod->ATTFlashSwitch = POSE_OK;
			break;
		}
		//模式切换相关参数
		case ATT_CMDCODE_MODPARAM:
		{
			tmpWorkModPre = *tmpData;
			tmpWorkMod = *(tmpData + 1);
			tmpWlimit = DoGetFloatFrom8(tmpData+2) *ANG2RADIAN;
			tmpAlimit = DoGetFloatFrom8(tmpData+6) *ANG2RADIAN;
			tmpTimeLmt = DoGetInt16From8(tmpData+10);
			tmpTimeLmt1 = DoGetInt16From8(tmpData+12);
			tmpAngm = DoGetFloatFrom8(tmpData+14);
			if((tmpWorkMod & 0x0F) > 0x0B)
			{
				m_pZKTaskInfo->iCmdRes = ERR_CODE_CMDCODE;
				break;
			}

			if(ATTMOD_RATEDMP == tmpWorkModPre)
			{
				tmpConst->judge_time2 = tmpTimeLmt;
				tmpConst->RateThr_2T3	=tmpWlimit;
				tmpConst->HWHLThr_2T3 = tmpAngm;
			}

			else if(ATTMOD_MagTOSUN == tmpWorkModPre)
			{
				tmpConst->judge_time4 = tmpTimeLmt;
				tmpConst->AngThr_3TB = tmpAlimit;
				tmpConst->RateThr_3TB = tmpWlimit;
			}
			break;
		}
			
		//太敏
		case ATT_CMDCODE_ASS:
		{
			tmpCOMDCHOICE =*(tmpData) ;
				
			switch (tmpCOMDCHOICE)
			{
				case    0x11 :
				{
					tmpConst->Ass_MinFour_limt[0] = DoGetFloatFrom8(tmpData+1 +0);						//4片模拟太敏电压阈值
					tmpConst->Ass_MaxFour_limt[0] = DoGetFloatFrom8(tmpData+1 +4);						//4片模拟太敏电压阈值
					break;
				}
				case	0x22:
				{
					tmpConst->Ass_MinFour_limt[1] = DoGetFloatFrom8(tmpData+1 +0);						//4片模拟太敏电压阈值
					tmpConst->Ass_MaxFour_limt[1] = DoGetFloatFrom8(tmpData+1 +4);						//4片模拟太敏电压阈值
					break;
				}
				default:
				break;
			}
			break;
		}

		//单机使用状态
		case ATT_CMDCROSSUSE:
		{
			pIMU->SSUseState[0] = *(tmpData);
			pIMU->SSUseState[1] = *(tmpData + 1);
			pIMU->SSUseState[2] = *(tmpData + 2);
			pIMU->AssUseState[0] = *(tmpData + 3);
			pIMU->AssUseState[1] = *(tmpData + 4);
			pIMU->AssUseState[2] = *(tmpData + 5);
			pIMU->AssUseState[3] = *(tmpData + 6);
			pIMU->AssUseState[4] = *(tmpData + 7);
			pIMU->AssUseState[5] = *(tmpData + 8);
			pIMU->MagUseState[0] = *(tmpData + 9);
			pIMU->MagUseState[1] = *(tmpData + 10);
			pIMU->GyroUseState[0] = *(tmpData + 11);
			pIMU->GyroUseState[1] = *(tmpData + 12);
			pIMU->GyroUseState[2] = *(tmpData + 13);
			pIMU->Whl_Use[0] = *(tmpData + 14);
			pIMU->Whl_Use[1] = *(tmpData + 15);
			pIMU->Whl_Use[2] = *(tmpData + 16);
			pIMU->Whl_Use[3] = *(tmpData + 17);
			pIMU->MTUseStatus[0] = *(tmpData + 18);
			pIMU->MTUseStatus[1] = *(tmpData + 19);
			pIMU->MTUseStatus[2] = *(tmpData + 20);
			pIMU->MTUseStatus[3] = *(tmpData + 21);
			pIMU->PPUUseStatus= *(tmpData + 22);
			break;
		}

		//单机重构状态注入
		case ATT_CMDCROSS:
		{
			//星敏优先级
			if (*(tmpData+0) != *(tmpData +1))
			{
				if (*(tmpData+0) != *(tmpData +2))
				{
					tmpConst->SSUsePrior[0]= *(tmpData) ;
					tmpConst->SSUsePrior[1]= *(tmpData +1) ;
					tmpConst->SSUsePrior[2]= *(tmpData +2) ;
				}
			}

			//陀螺优先级
			if (*(tmpData+3) != *(tmpData +4))
			{
				if (*(tmpData+3) != *(tmpData +5))
				{
					tmpConst->GyroUsePrior[0]= *(tmpData +3) ;
					tmpConst->GyroUsePrior[1]= *(tmpData +4) ;
					tmpConst->GyroUsePrior[2]= *(tmpData +5) ;
				}
			}
			break;
		}
		case ATT_CMDCREUSE:
		{
			tmpConst->AttCmdFlashPara.Mag_ComRESW[0] = *(tmpData);
			tmpConst->AttCmdFlashPara.Mag_ComRESW[1] = *(tmpData+1);
			tmpConst->AttCmdFlashPara.Mag_ComRESW[2] = *(tmpData+2);
				
			tmpConst->AttCmdFlashPara.Gyro_ComRESW[0] = *(tmpData+3);
			tmpConst->AttCmdFlashPara.Gyro_ComRESW[1] = *(tmpData+4);
			tmpConst->AttCmdFlashPara.Gyro_ComRESW[2] = *(tmpData+5);
			pWMod->ATTFlashSwitch = POSE_OK;
			break;		
		}

		/**********************************安装矩阵*********************************/
		//星敏安装矩阵注入
		case ATT_CMDCODE_SSMAT:
		{
			tmpCOMDCHOICE =*(tmpData) ;
			switch (tmpCOMDCHOICE)
			{
				case    0x11 :
				{
					for(i=0; i<3; i++)
					{
						for (k=0; k<3; k++)
						{
							tmpConst->AttCmdFlashPara.M_SSA[i][k] = DoGetFloatFrom8(tmpData+i*12+k*4 + 1);
						}
					}
					break;
				}
				case    0x22 :
				{
					for(i=0; i<3; i++)
					{
						for (k=0; k<3; k++)
						{
							tmpConst->AttCmdFlashPara.M_SSB[i][k] = DoGetFloatFrom8(tmpData+i*12+k*4 + 1);
						}
					}
					break;
				}
				case    0x44 :
				{
					for(i=0; i<3; i++)
					{
						for (k=0; k<3; k++)
						{
							tmpConst->AttCmdFlashPara.M_SSC[i][k] = DoGetFloatFrom8(tmpData+i*12+k*4 + 1);
						}
					}
					break;
				}
				default:
				break;
			}
			pWMod->ATTFlashSwitch = POSE_OK;
			break;
		}
			
		//太敏安装矩阵注入
		case ATT_CMDCODE_ASSMAT:
		{
			tmpDevNO = *tmpData;   //太敏选择
			if(0x11 == tmpDevNO)
			{
				for(i=0; i<3; i++)
				{
					for (k=0; k<3; k++)
					{
						tmpConst->AttCmdFlashPara.M_aSSA[i][k] =  DoGetFloatFrom8(tmpData+i*12+k*4+1);
					}
				}
			}
			else if(0x22 == tmpDevNO)
			{
				for(i=0; i<3; i++)
				{
					for (k=0; k<3; k++)
					{
						tmpConst->AttCmdFlashPara.M_aSSB[i][k] =  DoGetFloatFrom8(tmpData+i*12+k*4+1);
					}
				}
			}
			else if(0x33 == tmpDevNO)
			{
				for(i=0; i<3; i++)
				{
					for (k=0; k<3; k++)
					{
						tmpConst->AttCmdFlashPara.M_aSSC[i][k] =  DoGetFloatFrom8(tmpData+i*12+k*4+1);
					}
				}
			}
			else if(0x44 == tmpDevNO)
			{
				for(i=0; i<3; i++)
				{
					for (k=0; k<3; k++)
					{
						tmpConst->AttCmdFlashPara.M_aSSD[i][k] =  DoGetFloatFrom8(tmpData+i*12+k*4+1);
					}
				}
			}
			else if(0x55 == tmpDevNO)
			{
				for(i=0; i<3; i++)
				{
					for (k=0; k<3; k++)
					{
						tmpConst->AttCmdFlashPara.M_aSSE[i][k] =  DoGetFloatFrom8(tmpData+i*12+k*4+1);
					}
				}
			}
			else if(0x66 == tmpDevNO)
			{
				for(i=0; i<3; i++)
				{
					for (k=0; k<3; k++)
					{
						tmpConst->AttCmdFlashPara.M_aSSF[i][k] =  DoGetFloatFrom8(tmpData+i*12+k*4+1);
					}
				}
			}
			else
			{
				//m_pZKTaskInfo->iCmdRes = ERR_CODE_CMDCODE;
			}
			pWMod->ATTFlashSwitch = POSE_OK;
			break;
		}

		//磁强计安装矩阵注入
		case ATT_CMDCODE_MAGMAT:
		{
			tmpCOMDCHOICE =*(tmpData) ;
			switch (tmpCOMDCHOICE)
			{
				case    0x11 :
				{
					for(i=0; i<3; i++)
					{
						for(k=0; k<3; k++)
						{
							tmpConst->AttCmdFlashPara.M_MAG[0][i][k] =  DoGetFloatFrom8(tmpData+i*12+k*4 +1);
						}
					}
					break;
				}
				case    0x22 :
				{
					for(i=0; i<3; i++)
					{
						for(k=0; k<3; k++)
						{
							tmpConst->AttCmdFlashPara.M_MAG[1][i][k] =  DoGetFloatFrom8(tmpData+i*12+k*4 +1);
						}
					}
					break;
				}
				default:
				break;
			}
			pWMod->ATTFlashSwitch = POSE_OK;
			break;
		}

		//陀螺安装矩阵注入
		case ATT_CMDCODE_GyroMAT:
		{
			tmpCOMDCHOICE =*(tmpData) ;
			switch (tmpCOMDCHOICE)
			{
				case    0x11 :
				{
					for(i=0; i<3; i++)
					{
						for (k=0; k<3; k++)
						{
							tmpConst->AttCmdFlashPara.M_GYRO[0][i][k] = DoGetFloatFrom8(tmpData+i*12+k*4 +1);
						}
					}
					break;
				}
				case    0x22 :
				{
					for(i=0; i<3; i++)
					{
						for (k=0; k<3; k++)
						{
							tmpConst->AttCmdFlashPara.M_GYRO[1][i][k] = DoGetFloatFrom8(tmpData+i*12+k*4 +1);
						}
					}
					break;
				}
				case    0x44 :
				{
					for(i=0; i<3; i++)
					{
						for (k=0; k<3; k++)
						{
							tmpConst->AttCmdFlashPara.M_GYRO[2][i][k] = DoGetFloatFrom8(tmpData+i*12+k*4 +1);
						}
					}
					break;
				}
				default:
				break;
			}
			pWMod->ATTFlashSwitch = POSE_OK;
			break;
		}

		//反作用轮安装矩阵注入
		case ATT_CMDCODE_WHLMAT:
		{
			tmpCOMDCHOICE =*(tmpData) ;
			switch (tmpCOMDCHOICE)
			{
				case    0x11 :
				{
					for(i=0; i<3; i++)
					{
						tmpConst->AttCmdFlashPara.M_Wheel[i][0] = DoGetFloatFrom8(tmpData+i*4 +1);
					}
					break;
				}
				case    0x22 :
				{
					for(i=0; i<3; i++)
					{
						tmpConst->AttCmdFlashPara.M_Wheel[i][1] = DoGetFloatFrom8(tmpData+i*4 +1);
					}
					break;
				}
				case    0x44 :
				{
					for(i=0; i<3; i++)
					{
						tmpConst->AttCmdFlashPara.M_Wheel[i][2] = DoGetFloatFrom8(tmpData+i*4 +1);
					}
					break;
				}
					
				case    0x88 :
				{
					for(i=0; i<3; i++)
					{
						tmpConst->AttCmdFlashPara.M_Wheel[i][3] = DoGetFloatFrom8(tmpData+i*4 +1);
					}
					break;
				}
				default:
				break;
			}
			pWMod->ATTFlashSwitch = POSE_OK;
			break;
		}

		//磁力矩器安装矩阵注入
		case ATT_CMDCODE_MTMAT:
		{
			tmpCOMDCHOICE =*(tmpData) ;
			switch (tmpCOMDCHOICE)
			{
				case    0x11 :
				{
					for(i=0; i<3; i++)
					{
						tmpConst->AttCmdFlashPara.M_MAGCtrl[i][0] =  DoGetFloatFrom8(tmpData+i*4 +1);
					}
					break;
				}
				case    0x22 :
				{
					for(i=0; i<4; i++)
					{
						tmpConst->AttCmdFlashPara.M_MAGCtrl[i][1] =  DoGetFloatFrom8(tmpData+i*4 +1);
					}
					break;
				}
				case    0x44 :
				{
					for(i=0; i<4; i++)
					{
						tmpConst->AttCmdFlashPara.M_MAGCtrl[i][2] =  DoGetFloatFrom8(tmpData+i*4 +1);
					}
					break;
				}
					
				case    0x88 :
				{
					for(i=0; i<4; i++)
					{
						tmpConst->AttCmdFlashPara.M_MAGCtrl[i][3] =  DoGetFloatFrom8(tmpData+i*4 +1);
					}
					break;
				}
				default:
				break;
			}
			pWMod->ATTFlashSwitch = POSE_OK;
			break;
		}

		//磁阻尼控制器注入
		case ATT_CMDCODE_DMPPARA:
		{
			tmpConst->Mag_Bb_CtrlMax = DoGetFloatFrom8(tmpData);
			tmpConst->Mag_DampBdotMin = DoGetFloatFrom8(tmpData+4);
			tmpConst->MTCtrlTIME= DoGetInt16From8(tmpData+ 8);
			break;
		}
			
		//磁控对日控制器参数注入
		case ATT_CMDCODE_TOSUNPARA:
		{
			tmpCOMDCHOICE =*(tmpData) ;
			switch (tmpCOMDCHOICE)
			{
				case    0x55 :
				{
					for (i = 0; i < 3; i++)
					{
						tmpConst->Mag_Kd[i] = DoGetFloatFrom8(tmpData+i*4 +1);
					}
					for (i = 0; i < 3; i++)
					{
						tmpConst->Mag_Kp[i] = DoGetFloatFrom8(tmpData+i*4+ 12+1);
					}
					tmpConst->Mag_WTOSUN=DoGetFloatFrom8(tmpData + 12 + 12 +1) *ANG2RADIAN ;	
					break;
				}

				case    0xAA :
				{
					for (i = 0; i < 3; i++)
					{
						tmpConst->Mag_KpFBZK[i] = DoGetFloatFrom8(tmpData+i*4+1);
					}
					for (i = 0; i < 3; i++)
					{
						tmpConst->Mag_KdFBZK[i] = DoGetFloatFrom8(tmpData+i*4+ 12+1);
					}
					tmpConst->Mag_FBZKWTOSUN=DoGetFloatFrom8(tmpData + 12 + 12 +1) *ANG2RADIAN ;	
					break;
				}
				default:
				break;
			}
			tmpConst->Mag_ATTTOSUN=DoGetFloatFrom8(tmpData + 12 + 12 + 4+1) *ANG2RADIAN;
				
			break;
		}

		//陀螺零偏注入
		case ATT_CMDCODE_GyroBIAS:
		{
			tmpWorkMod =*tmpData;
			if (0x11==tmpWorkMod)
			{
				for (k = 0; k < 3; k++)
				{
					tmpConst->AttCmdFlashPara.Gyro_Comd_Bias[0][k] =DoGetFloatFrom8(tmpData+k*4 +1)* ANG2RADIAN;     //陀螺零偏
				}
			}
			else if (0x22==tmpWorkMod)
			{
				for (k = 0; k < 3; k++)
				{
					tmpConst->AttCmdFlashPara.Gyro_Comd_Bias[1][k] =DoGetFloatFrom8(tmpData+k*4 +1)* ANG2RADIAN;     //陀螺零偏
				}
			}
			else if (0x44==tmpWorkMod)
			{
				for (k = 0; k < 3; k++)
				{
					tmpConst->AttCmdFlashPara.Gyro_Comd_Bias[2][k] =DoGetFloatFrom8(tmpData+k*4 +1)* ANG2RADIAN;     //陀螺零偏
				}
			}
			pWMod->ATTFlashSwitch = POSE_OK;
			break;
		}

		//陀螺标度因数注入
		case ATT_CMDCODE_GyroPH:
		{
			tmpWorkMod =*tmpData;
			if (0x11==tmpWorkMod)
			{
				for (i = 0; i < 3; i++)
				{
					for (j = 0; j< 3; j++)
					{
						tmpConst->AttCmdFlashPara.Gyro_Comd_K[0][i][j] =DoGetFloatFrom8(tmpData+i*12+j*4+1);     //陀螺标度因数
					}
				}
			}
			else if (0x22==tmpWorkMod)
			{
				for (i = 0; i < 3; i++)
				{
					for (j = 0; j< 3; j++)
					{
						tmpConst->AttCmdFlashPara.Gyro_Comd_K[1][i][j] =DoGetFloatFrom8(tmpData+i*12+j*4+1);     //陀螺标度因数
					}
				}
			}
			else if (0x44==tmpWorkMod)
			{
				for (i = 0; i < 3; i++)
				{
					for (j = 0; j< 3; j++)
					{
						tmpConst->AttCmdFlashPara.Gyro_Comd_K[2][i][j] =DoGetFloatFrom8(tmpData+i*12+j*4+1);     //陀螺标度因数
					}
				}
			}
			pWMod->ATTFlashSwitch = POSE_OK;
			break;
		}	
		//磁强计标定系数注入
		case ATT_CMDCODE_MTBD:
		{
			memset(tmpCOMDCHOICE,0x00,sizeof(UINT8));
			tmpCOMDCHOICE =*tmpData;
			if (0x11==tmpCOMDCHOICE)
			{
				for (i = 0; i< 3; i++)
				{
					tmpConst->AttCmdFlashPara.MAG_LK[0][i]=DoGetFloatFrom8(tmpData+i*4+1);
					tmpConst->AttCmdFlashPara.MAG_LB[0][i]=DoGetFloatFrom8(tmpData+12+i*4+1);
				}
			}
			else if (0x22==tmpCOMDCHOICE)
			{
				for (i = 0; i< 3; i++)
				{
					tmpConst->AttCmdFlashPara.MAG_LK[1][i]=DoGetFloatFrom8(tmpData+i*4+1);
					tmpConst->AttCmdFlashPara.MAG_LB[1][i]=DoGetFloatFrom8(tmpData+12+i*4+1);
				}
			}
			break;
		}
			
		//磁力矩器分配-磁矩限值
		case ATT_CMDCODE_MTCTRL:
		{
			tmpConst->MTOutXYZLimit[0] = DoGetFloatFrom8(tmpData);
			tmpConst->MTOutXYZLimit[1] = DoGetFloatFrom8(tmpData +4);
			tmpConst->MTOutXYZLimit[2] = DoGetFloatFrom8(tmpData +8);
			tmpConst->MTOutXYZLimit[3] = DoGetFloatFrom8(tmpData +12);
			break;
		}
		default:
		{
			//m_pZKTaskInfo->iCmdRes = ERR_CODE_CMDCODE;
			break;
		}			
	}
#endif
}


//姿控单机加电状态获取
void ZKPowerState(void)
{
	UINT8	i= 0x00;
	sAttPriData *tmpAtt = NULL;
	sAttErrCtlPara_t 	*pREcheck= NULL;	
	sDevInfo  *tmpDevInfo= NULL;	
	tmpAtt=(sAttPriData *)ATTCLT_DATA1_ADDR;
	if(NULL ==tmpAtt)
	return;
	pREcheck=&tmpAtt->sErrCtlPara;	
	
	//初始化\星敏
	//陀螺
	for(i=0; i<3; i++)
	{
		pREcheck->ssIn_PowerOn[i] = POSE_NO;
		pREcheck->GyroIn_PowerOn[i] = POSE_NO;	
	}
	
	//飞轮
	for(i=0; i<4; i++)
	{
		pREcheck->WhlIn_PowerOn[i] = POSE_NO;
	}
	
	//磁强计
	for(i=0; i<2; i++)
	{
		pREcheck->MagIn_PowerOn[i] = POSE_NO;	
	}
	//电推
	pREcheck->PPUIn_PowerOn = POSE_NO;
	
	//星敏A
	tmpDevInfo = GETDEVINFO(DEV_NO_UART15);	
	if(0x10 == (tmpDevInfo->sPowerInfo.bStart & 0x10))
	{
		pREcheck->ssIn_PowerOn[0] = POSE_OK;
		if(pREcheck->ss_PowerOnCnt[0]<60000)
		pREcheck->ss_PowerOnCnt[0]++;     		//星敏加电状态计数		
	}
	else
	{
		pREcheck->ss_PowerOnCnt[0] = 0;		
	}

	//星敏B
	tmpDevInfo = GETDEVINFO(DEV_NO_UART16);
	if(0x10 == (tmpDevInfo->sPowerInfo.bStart & 0x10))
	{
		pREcheck->ssIn_PowerOn[1] = POSE_OK;
		if(pREcheck->ss_PowerOnCnt[1]<60000)
		pREcheck->ss_PowerOnCnt[1]++;     		//星敏加电状态计数
	}
	else
	{
		pREcheck->ss_PowerOnCnt[1] = 0;
	}

	//星敏C
	tmpDevInfo = GETDEVINFO(DEV_NO_UART4);
	if(0x10 == (tmpDevInfo->sPowerInfo.bStart & 0x10))
	{
		pREcheck->ssIn_PowerOn[2] = POSE_OK;
		if(pREcheck->ss_PowerOnCnt[2]<60000)
		pREcheck->ss_PowerOnCnt[2]++;     		//星敏加电状态计数
	}
	else
	{
		pREcheck->ss_PowerOnCnt[2] = 0;
	}	
	//陀螺A
	tmpDevInfo = GETDEVINFO(DEV_NO_UART5);
	if(0x10 == (tmpDevInfo->sPowerInfo.bStart & 0x10))
	{
		pREcheck->GyroIn_PowerOn[0] = POSE_OK;
		if(pREcheck->Gyro_PowerOnCnt[0]<60000)
		   pREcheck->Gyro_PowerOnCnt[0]++;     		//陀螺加电状态计数		
	}
	else
	{
		pREcheck->Gyro_PowerOnCnt[0] =0;
	}
	//陀螺B
	tmpDevInfo = GETDEVINFO(DEV_NO_UART6);
	if(0x10 == (tmpDevInfo->sPowerInfo.bStart & 0x10))
	{
		pREcheck->GyroIn_PowerOn[1] = POSE_OK;
		if(pREcheck->Gyro_PowerOnCnt[1]<60000)
		pREcheck->Gyro_PowerOnCnt[1]++;     		//陀螺加电状态计数
	}
	else
	{
		pREcheck->Gyro_PowerOnCnt[1] =0;
	}
	//陀螺C
	tmpDevInfo = GETDEVINFO(DEV_NO_UART7);
	if(0x10 == (tmpDevInfo->sPowerInfo.bStart & 0x10))
	{
		pREcheck->GyroIn_PowerOn[2] = POSE_OK;
		if(pREcheck->Gyro_PowerOnCnt[2]<60000)
		pREcheck->Gyro_PowerOnCnt[2]++;     		//陀螺加电状态计数
	}
	else
	{
		pREcheck->Gyro_PowerOnCnt[2] =0;
	}
	//飞轮A
	tmpDevInfo = GETDEVINFO(DEV_NO_UART8);
	if(0x10 == (tmpDevInfo->sPowerInfo.bStart & 0x10))         
	{
		pREcheck->WhlIn_PowerOn[0] = POSE_OK;
		if(pREcheck->Whl_PowerOnCnt[0]<60000)
		pREcheck->Whl_PowerOnCnt[0]++;     		//陀螺加电状态计数
	}
	else
	{
		pREcheck->Whl_PowerOnCnt[0] =0;
	}
	//飞轮B
	tmpDevInfo = GETDEVINFO(DEV_NO_UART9);
	if(0x10 == (tmpDevInfo->sPowerInfo.bStart & 0x10))
	{
		pREcheck->WhlIn_PowerOn[1] = POSE_OK;
		if(pREcheck->Whl_PowerOnCnt[1]<60000)
		pREcheck->Whl_PowerOnCnt[1]++;     		//陀螺加电状态计数
	}
	else
	{
		pREcheck->Whl_PowerOnCnt[1] =0;
	}
	//飞轮C
	tmpDevInfo = GETDEVINFO(DEV_NO_UART10);
	if(0x10 == (tmpDevInfo->sPowerInfo.bStart & 0x10))
	{
		pREcheck->WhlIn_PowerOn[2] = POSE_OK;
		if(pREcheck->Whl_PowerOnCnt[2]<60000)
		pREcheck->Whl_PowerOnCnt[2]++;     		//陀螺加电状态计数
	}
	else
	{
		pREcheck->Whl_PowerOnCnt[2] =0;
	}
	//飞轮D
	tmpDevInfo = GETDEVINFO(DEV_NO_UART11);
	if(0x10 == (tmpDevInfo->sPowerInfo.bStart & 0x10))
	{
		pREcheck->WhlIn_PowerOn[3] = POSE_OK;
		if(pREcheck->Whl_PowerOnCnt[3]<60000)
		pREcheck->Whl_PowerOnCnt[3]++;     		//陀螺加电状态计数
	}
	else
	{
		pREcheck->Whl_PowerOnCnt[3] =0;
	}

	//磁强计A
	tmpDevInfo = GETDEVINFO(DEV_NO_CQJ);
	if(0x10 == (tmpDevInfo->sPowerInfo.bStart & 0x10))
	{
		pREcheck->MagIn_PowerOn[0] = POSE_OK;
		if(pREcheck->Mag_PowerOnCnt[0]<60000)
		pREcheck->Mag_PowerOnCnt[0]++;     		
	}
	else
	{
		pREcheck->Mag_PowerOnCnt[0] =0;
	}

	//磁强计B
	tmpDevInfo = GETDEVINFO(DEV_NO_CQJ);
	if(0x20 == (tmpDevInfo->sPowerInfo.bStart & 0x20))
	{
		pREcheck->MagIn_PowerOn[1] = POSE_OK;
		if(pREcheck->Mag_PowerOnCnt[1]<60000)
		pREcheck->Mag_PowerOnCnt[1]++;
	}
	else
	{
		pREcheck->Mag_PowerOnCnt[1] =0;
	}
	
	//电推
	tmpDevInfo = GETDEVINFO(DEV_NO_CAN0);
	if(0x10 == (tmpDevInfo->sPowerInfo.bStart & 0x10))
	{
		pREcheck->PPUIn_PowerOn = POSE_OK;
		if(pREcheck->PPU_PowerOnCnt<60000)
		pREcheck->PPU_PowerOnCnt++;     		//星敏加电状态计数
	}
	else
	{
		pREcheck->PPU_PowerOnCnt = 0;
	}		
}



/**************************************
**说明：存储数据恢复模式切换
**输入：@index标志位，
***************************************/
void	ZKReModBK(void)
{
	UINT8 	tmpNewMod = ATTMOD_RATEDMP ;
	
	sAttPriData *tmpAtt = NULL;
	OrbitPriData_t *tmpOrbit= NULL;
		
	tmpOrbit = (OrbitPriData_t *)ORBIT_BASE_ADDR;
	tmpAtt=(sAttPriData *)ATTCLT_DATA1_ADDR;

	if((NULL == tmpAtt) || (NULL == tmpOrbit))
	{
		return ;
	}
	
	tmpNewMod = tmpAtt->sModePara.WorkMode;	
	
	switch(tmpAtt->sModePara.WorkMode)
	{
		case ATTMOD_BREAKPRE:              /*星箭分离前 0x00*/
		{
			tmpNewMod = ATTMOD_NOCOLL;
			break;
		}
		case ATTMOD_UNCTL:				   /*无控模式   0xBB*/
		{
			tmpNewMod = ATTMOD_RATEDMP;
			break;
		}
		case ATTMOD_ONLTOTAR:			   /*对目标定向 0xAA*/
		case ATTMOD_ATTAJUST:			   /*定向前调姿 0x99*/
		case ATTMOD_ONLTOEARTH:			   /*对地定向   0x55*/
		case ATTMOD_WHEELTOEARTH:		   /*稳态对地   0x66*/
		{
			if (POSE_OK ==	tmpOrbit->sCalOutData.ObtOutVldLast)
			{
				tmpNewMod = tmpAtt->sModePara.WorkMode;
			} 
			else
			{
				tmpNewMod = ATTMOD_RATEDMP;
			}
			break;
		}
		case ATTMOD_ATTAJUSTPRE:		  /*轨控前调姿 0x77*/
		case ATTMOD_ORBITCTL:			  /*轨道控制   0x88*/
		{
			/*2.5S后关PPU电源*/
			tmpAtt->sPerPara.PPUPara.PPU_OrbitCtl_Quit_Err_Flag = POSE_OK;
			tmpAtt->sPerPara.PPUPara.PPU_OrbitCtl_Quit_Err_Cnt = 0;
			
			tmpAtt->sPerPara.PPUPara.PPU_OrbitCtl_Quit_OK_Flag = POSE_NO;
			tmpAtt->sPerPara.PPUPara.PPU_OrbitCtl_Quit_OK_Cnt = 0;
			
			if (POSE_OK ==tmpOrbit->sCalOutData.ObtOutVldLast)
			{
				tmpNewMod = ATTMOD_ONLTOEARTH;
			}
			else
			{
				tmpNewMod = ATTMOD_RATEDMP;
			}
			break;
		}
		case ATTMOD_NOCOLL:				 /*碰撞规避模式  0x11 */
		case ATTMOD_RATEDMP:			 /*速率阻尼      0x22 */
		case ATTMOD_WhlTOSUN:			 /*轮控对日定向  0x33 */  
		case ATTMOD_MagTOSUN:			 /*磁控对日定向  0x44 */  
		{
			tmpNewMod = tmpAtt->sModePara.WorkMode;
			break;		
		}
		default:                         /*非姿控的工作模式，初始化为 速率阻尼*/
		{
			tmpNewMod = ATTMOD_RATEDMP;
			break;
		}
	}
	/*切换到新模式后，将相关计数器清零*/
	ZKModDoSet(tmpNewMod);
}

/************************************************FLASH********************************************************************/
/**************************************
**说明：读取FLASH数据
**输入：
***************************************/
void	ZKREFlashBK(void)
{
	AttCtrlConst_t *tmpConst = (AttCtrlConst_t *)ATTCLT_DATA2_ADDR;
	sWheelIdArray		*tmpBKStr	=	(sWheelIdArray *)ST_WHEEL_ID_ARRAY_ADDR;
	if((NULL == tmpConst) ||(NULL == tmpBKStr))
	{
		return ;
	}
	if(tmpBKStr->WHEEL_ID_ARRAY[0][0] == 0X11)
	{
		tmpConst->Whl_ID[0]= tmpBKStr->WHEEL_ID_ARRAY[0][1];
	}

	if(tmpBKStr->WHEEL_ID_ARRAY[1][0] == 0X22)
	{
		tmpConst->Whl_ID[1]= tmpBKStr->WHEEL_ID_ARRAY[1][1];
	}

	if(tmpBKStr->WHEEL_ID_ARRAY[2][0] == 0X33)
	{
		tmpConst->Whl_ID[2]= tmpBKStr->WHEEL_ID_ARRAY[2][1];
	}
	if(tmpBKStr->WHEEL_ID_ARRAY[3][0] == 0X44)
	{
		tmpConst->Whl_ID[3]= tmpBKStr->WHEEL_ID_ARRAY[3][1];
	}	
	
}

/************************************************三取二********************************************************************/
/***********************************************
说明：用于重要变量三取二
输入：pTDATA , pSDATA
输出：
返回:
注意:输入、输出变量均为UINT8类型
***********************************************/
void ATTGet2Base3FromBuff(UINT8 *pTDATA, UINT8 *pSDATA)
{
	if((NULL == pSDATA) || (NULL == pTDATA)) 
	{
		return;
	}

	if(!(pSDATA[0]^pSDATA[1])) 
	{
		*pTDATA = pSDATA[0];
	}
	else if(!(pSDATA[0]^pSDATA[2])) 
	{
		*pTDATA = pSDATA[2];
	}
	else if(!(pSDATA[1]^pSDATA[2])) 
	{
		*pTDATA = pSDATA[1];
	}
	else 
	{
		;                                                                                                               /*不做处理*/
	}
}

/***********************************************
说明：用于对重要数据备份，备三份，便于每周期进行更新
输入：pTDATA , pSDATA
输出：
返回:
注意:输入、输出变量均为UINT8类型
***********************************************/
void ATTSetBase3ToBuff(UINT8 *pTDATA, UINT8 *pSDATA)
{
	if((NULL == pSDATA) || (NULL == pTDATA)) 
	{
		return;
	}

	pSDATA[0] = *pTDATA;
	pSDATA[1] = *pTDATA;
	pSDATA[2] = *pTDATA;
}

/***********************************************
说明：每周期对重要数据进行更新
注意:输入、输出变量均为UINT8类型
***********************************************/
void ATTGetImportDataFromBuff(void)
{
	UINT8 i = 0X00;
	sAttPriData *tmpAtt = NULL;
	AttCtrlConst_t *tmpConst = NULL;

	tmpAtt=(sAttPriData *)ATTCLT_DATA1_ADDR;
	tmpConst=(AttCtrlConst_t *)ATTCLT_DATA2_ADDR;
	if((NULL == tmpAtt) || (NULL == tmpConst))
	{
		return;
	}

	//if(POSE_OK == tmpAtt->AttData3T2Para.AttCtlBKFlag)
	//{
		//tmpAtt->AttData3T2Para.AttCtlBKFlag = POSE_NO;
		ATTGet2Base3FromBuff(&tmpAtt->sModePara.WorkMode, &tmpAtt->AttData3T2Para.WorkModeBK[0]);
		ATTGet2Base3FromBuff(&tmpConst->AttCmdFlashPara.WorkModeChangeAuto, &tmpAtt->AttData3T2Para.WorkModeChangeAutoBK[0]);
		for (i = 0; i < STAR_NUM; ++i)
		{
			ATTGet2Base3FromBuff(&tmpAtt->sErrCtlPara.SS_err[i], &tmpAtt->AttData3T2Para.SS_errBK[i][0]);
		}
		for (i = 0; i < MAG_NUM; ++i)
		{
			ATTGet2Base3FromBuff(&tmpAtt->sErrCtlPara.Mag_err[i], &tmpAtt->AttData3T2Para.Mag_errBK[i][0]);
		}
		for (i = 0; i < GYRO_NUM; ++i)
		{
			ATTGet2Base3FromBuff(&tmpAtt->sErrCtlPara.Gyro_err[i], &tmpAtt->AttData3T2Para.Gyro_errBK[i][0]);
		}
		for (i = 0; i < WHEEL_NUM; ++i)
		{
			ATTGet2Base3FromBuff(&tmpAtt->sErrCtlPara.Whl_Err[i], &tmpAtt->AttData3T2Para.Whl_ErrBK[i][0]);
		}
		ATTGet2Base3FromBuff(&tmpAtt->sErrCtlPara.PPU_Err, &tmpAtt->AttData3T2Para.PPU_ErrBK[0]);
		for (i = 0; i < STAR_NUM; ++i)
		{
			ATTGet2Base3FromBuff(&tmpAtt->sIMPTPara.SSUseState[i], &tmpAtt->AttData3T2Para.SSUseStateBK[i][0]);
		}
		for (i = 0; i < ASS_NUM; ++i)
		{
			ATTGet2Base3FromBuff(&tmpAtt->sIMPTPara.AssUseState[i], &tmpAtt->AttData3T2Para.AssUseStateBK[i][0]);
		}
		for (i = 0; i < MAG_NUM; ++i)
		{
			ATTGet2Base3FromBuff(&tmpAtt->sIMPTPara.MagUseState[i], &tmpAtt->AttData3T2Para.MagUseStateBK[i][0]);
		}
		for (i = 0; i < GYRO_NUM; ++i)
		{
			ATTGet2Base3FromBuff(&tmpAtt->sIMPTPara.GyroUseState[i], &tmpAtt->AttData3T2Para.GyroUseStateBK[i][0]);
		}
		for (i = 0; i < WHEEL_NUM; ++i)
		{
			ATTGet2Base3FromBuff(&tmpAtt->sIMPTPara.Whl_Use[i], &tmpAtt->AttData3T2Para.Whl_UseBK[i][0]);
		}
		for (i = 0; i < MT_NUM; ++i)
		{
			ATTGet2Base3FromBuff(&tmpAtt->sIMPTPara.MTUseStatus[i], &tmpAtt->AttData3T2Para.MTUseStatusBK[i][0]);
		}
		ATTGet2Base3FromBuff(&tmpAtt->sIMPTPara.PPUUseStatus, &tmpAtt->AttData3T2Para.PPUUseStatusBK[0]);
		for (i = 0; i < 3; ++i)
		{
			ATTGet2Base3FromBuff(&tmpConst->AttCmdFlashPara.Gyro_ComRESW[i], &tmpAtt->AttData3T2Para.Gyro_ComRESWBK[i][0]);
		}
		for (i = 0; i < 3; ++i)
		{
			ATTGet2Base3FromBuff(&tmpConst->AttCmdFlashPara.Mag_ComRESW[i], &tmpAtt->AttData3T2Para.Mag_ComRESWBK[i][0]);
		}
		for (i = 0; i < STAR_NUM; ++i)
		{
			ATTGet2Base3FromBuff(&tmpAtt->sPerPara.SsPara[i].ssPrior, &tmpAtt->AttData3T2Para.ssPriorBK[i][0]);
		}
		for (i = 0; i < GYRO_NUM; ++i)
		{
			ATTGet2Base3FromBuff(&tmpAtt->sPerPara.GyroPara[i].GyroPrior, &tmpAtt->AttData3T2Para.GyroPriorBK[i][0]);
		}
		
		for (i = 0; i < STAR_NUM; ++i)
		{
			ATTGet2Base3FromBuff(&tmpConst->AllowssONOFF[i], &tmpAtt->AttData3T2Para.AllowssONOFFBK[i][0]);
		}

		for (i = 0; i < GYRO_NUM; ++i)
		{
			ATTGet2Base3FromBuff(&tmpConst->AllowGyroONOFF[i], &tmpAtt->AttData3T2Para.AllowGyroONOFFBK[i][0]);
		}

		for (i = 0; i < MAG_NUM; ++i)
		{
			ATTGet2Base3FromBuff(&tmpConst->AllowMagONOFF[i], &tmpAtt->AttData3T2Para.AllowMagONOFFBK[i][0]);
		}

		for (i = 0; i < WHEEL_NUM; ++i)
		{
			ATTGet2Base3FromBuff(&tmpConst->AllowWhlONOFF[i], &tmpAtt->AttData3T2Para.AllowWhlONOFFBK[i][0]);
		}
		
		ATTGet2Base3FromBuff(&tmpConst->AllowPPUONOFF, &tmpAtt->AttData3T2Para.AllowPPUONOFFBK[0]);
			
		ATTGet2Base3FromBuff(&tmpConst->Allow_Sensor_CThr, &tmpAtt->AttData3T2Para.Allow_Sensor_CThrBK[0]);
		ATTGet2Base3FromBuff(&tmpConst->AllowAttLoseDiagFlg, &tmpAtt->AttData3T2Para.AllowAttLoseDiagFlgBK[0]);
		ATTGet2Base3FromBuff(&tmpConst->AllowAttExDiagFlg,	&tmpAtt->AttData3T2Para.AllowAttExDiagFlgBK[0]);
		ATTGet2Base3FromBuff(&tmpConst->AllowAttStaDiagFlg, &tmpAtt->AttData3T2Para.AllowAttStaDiagFlgBK[0]);
		
	//}
}

/*****************************************************************************
*名称:
*描述:
******************************************************************************/
void ATTImportDataBackup(void)
{
	UINT8 i = 0X00;
	sAttPriData *tmpAtt = NULL;
	AttCtrlConst_t *tmpConst = NULL;

	tmpAtt=(sAttPriData *)ATTCLT_DATA1_ADDR;
	tmpConst=(AttCtrlConst_t *)ATTCLT_DATA2_ADDR;
	if((NULL == tmpAtt) || (NULL == tmpConst))
	{
		return;
	}
	
	//tmpAtt->AttData3T2Para.AttCtlBKFlag = POSE_OK;
	ATTSetBase3ToBuff(&tmpAtt->sModePara.WorkMode, &tmpAtt->AttData3T2Para.WorkModeBK[0]);
	ATTSetBase3ToBuff(&tmpConst->AttCmdFlashPara.WorkModeChangeAuto, &tmpAtt->AttData3T2Para.WorkModeChangeAutoBK[0]);
	for (i = 0; i < STAR_NUM; ++i)
	{
		ATTSetBase3ToBuff(&tmpAtt->sErrCtlPara.SS_err[i], &tmpAtt->AttData3T2Para.SS_errBK[i][0]);
	}
	for (i = 0; i < MAG_NUM; ++i)
	{
		ATTSetBase3ToBuff(&tmpAtt->sErrCtlPara.Mag_err[i], &tmpAtt->AttData3T2Para.Mag_errBK[i][0]);
	}
	for (i = 0; i < GYRO_NUM; ++i)
	{
		ATTSetBase3ToBuff(&tmpAtt->sErrCtlPara.Gyro_err[i], &tmpAtt->AttData3T2Para.Gyro_errBK[i][0]);
	}
	for (i = 0; i < WHEEL_NUM; ++i)
	{
		ATTSetBase3ToBuff(&tmpAtt->sErrCtlPara.Whl_Err[i], &tmpAtt->AttData3T2Para.Whl_ErrBK[i][0]);
	}
	ATTSetBase3ToBuff(&tmpAtt->sErrCtlPara.PPU_Err, &tmpAtt->AttData3T2Para.PPU_ErrBK[0]);
	for (i = 0; i < STAR_NUM; ++i)
	{
		ATTSetBase3ToBuff(&tmpAtt->sIMPTPara.SSUseState[i], &tmpAtt->AttData3T2Para.SSUseStateBK[i][0]);
	}
	for (i = 0; i < ASS_NUM; ++i)
	{
		ATTSetBase3ToBuff(&tmpAtt->sIMPTPara.AssUseState[i], &tmpAtt->AttData3T2Para.AssUseStateBK[i][0]);
	}
	for (i = 0; i < MAG_NUM; ++i)
	{
		ATTSetBase3ToBuff(&tmpAtt->sIMPTPara.MagUseState[i], &tmpAtt->AttData3T2Para.MagUseStateBK[i][0]);
	}
	for (i = 0; i < GYRO_NUM; ++i)
	{
		ATTSetBase3ToBuff(&tmpAtt->sIMPTPara.GyroUseState[i], &tmpAtt->AttData3T2Para.GyroUseStateBK[i][0]);
	}
	for (i = 0; i < WHEEL_NUM; ++i)
	{
		ATTSetBase3ToBuff(&tmpAtt->sIMPTPara.Whl_Use[i], &tmpAtt->AttData3T2Para.Whl_UseBK[i][0]);
	}
	for (i = 0; i < MT_NUM; ++i)
	{
		ATTSetBase3ToBuff(&tmpAtt->sIMPTPara.MTUseStatus[i], &tmpAtt->AttData3T2Para.MTUseStatusBK[i][0]);
	}
	ATTSetBase3ToBuff(&tmpAtt->sIMPTPara.PPUUseStatus, &tmpAtt->AttData3T2Para.PPUUseStatusBK[0]);
	for (i = 0; i < 3; ++i)
	{
		ATTSetBase3ToBuff(&tmpConst->AttCmdFlashPara.Gyro_ComRESW[i], &tmpAtt->AttData3T2Para.Gyro_ComRESWBK[i][0]);
	}
	for (i = 0; i < 3; ++i)
	{
		ATTSetBase3ToBuff(&tmpConst->AttCmdFlashPara.Mag_ComRESW[i], &tmpAtt->AttData3T2Para.Mag_ComRESWBK[i][0]);
	}
	for (i = 0; i < STAR_NUM; ++i)
	{
		ATTSetBase3ToBuff(&tmpAtt->sPerPara.SsPara[i].ssPrior, &tmpAtt->AttData3T2Para.ssPriorBK[i][0]);
	}
	for (i = 0; i < GYRO_NUM; ++i)
	{
		ATTSetBase3ToBuff(&tmpAtt->sPerPara.GyroPara[i].GyroPrior, &tmpAtt->AttData3T2Para.GyroPriorBK[i][0]);
	}
	
	for (i = 0; i < STAR_NUM; ++i)
	{
		ATTSetBase3ToBuff(&tmpConst->AllowssONOFF[i], &tmpAtt->AttData3T2Para.AllowssONOFFBK[i][0]);
	}

	for (i = 0; i < GYRO_NUM; ++i)
	{
		ATTSetBase3ToBuff(&tmpConst->AllowGyroONOFF[i], &tmpAtt->AttData3T2Para.AllowGyroONOFFBK[i][0]);
	}

	for (i = 0; i < MAG_NUM; ++i)
	{
		ATTSetBase3ToBuff(&tmpConst->AllowMagONOFF[i], &tmpAtt->AttData3T2Para.AllowMagONOFFBK[i][0]);
	}

	for (i = 0; i < WHEEL_NUM; ++i)
	{
		ATTSetBase3ToBuff(&tmpConst->AllowWhlONOFF[i], &tmpAtt->AttData3T2Para.AllowWhlONOFFBK[i][0]);
	}
		
	ATTSetBase3ToBuff(&tmpConst->AllowPPUONOFF, &tmpAtt->AttData3T2Para.AllowPPUONOFFBK[0]);	
	
	ATTSetBase3ToBuff(&tmpConst->Allow_Sensor_CThr, &tmpAtt->AttData3T2Para.Allow_Sensor_CThrBK[0]);
	ATTSetBase3ToBuff(&tmpConst->AllowAttLoseDiagFlg, &tmpAtt->AttData3T2Para.AllowAttLoseDiagFlgBK[0]);
	ATTSetBase3ToBuff(&tmpConst->AllowAttExDiagFlg, &tmpAtt->AttData3T2Para.AllowAttExDiagFlgBK[0]);
	ATTSetBase3ToBuff(&tmpConst->AllowAttStaDiagFlg, &tmpAtt->AttData3T2Para.AllowAttStaDiagFlgBK[0]);
}


/************************************************双机FIFO********************************************************************/
/***********************************************
说明：姿控数据备份准备

***********************************************/
void    ZKDataBackUp(void)
{
	UINT8	i =  0X00;
	sAttPriData *tmpAtt = NULL;
	AttCtrlConst_t *tmpConst = NULL;
	sAttModPara_t *pWMod = NULL;
	AttBKPara_t   *pBK = NULL;
	sAttErrCtlPara_t 	*pREcheck = NULL;
	AttIMPTPara_t *pImpt = NULL;
	
	tmpAtt=(sAttPriData *)ATTCLT_DATA1_ADDR;	
	tmpConst=(AttCtrlConst_t *)ATTCLT_DATA2_ADDR;
	if((NULL == tmpAtt) || (NULL == tmpConst))
	{
		return;
	}
	pWMod =&tmpAtt->sModePara;
	pBK   =&tmpAtt->AttBKPara;
	pREcheck=&tmpAtt->sErrCtlPara;
	pImpt=&tmpAtt->sIMPTPara;
	//PGyro[0] = &tmpAtt->sPerPara.GyroPara[0];
	//PGyro[1] = &tmpAtt->sPerPara.GyroPara[1];
	//PGyro[2] = &tmpAtt->sPerPara.GyroPara[2];

	pBK->BK_WorkMode  = pWMod->WorkMode;
	pBK->BK_WorkModeChangeAuto = tmpConst->AttCmdFlashPara.WorkModeChangeAuto;
	for(i = 0;i<STAR_NUM;i++)
	{
		pBK->BK_SS_err[i] = pREcheck->SS_err[i];
	}
	for(i = 0;i<MAG_NUM;i++)
	{
		pBK->BK_Mag_err[i] = pREcheck->Mag_err[i];
	}
	for(i = 0;i<GYRO_NUM;i++)
	{
		pBK->BK_Gyro_err[i] = pREcheck->Gyro_err[i];
	}
	for(i = 0;i<WHEEL_NUM;i++)
	{
		pBK->BK_Whl_Err[i] = pREcheck->Whl_Err[i];
	}
	
	pBK->BK_PPU_Err = pREcheck->PPU_Err;
	
	for(i = 0;i<STAR_NUM;i++)
	{
		pBK->BK_SSUseState[i] = pImpt->SSUseState[i];
	}

	for(i = 0;i<GYRO_NUM;i++)
	{
		pBK->BK_GyroUseState[i] = pImpt->GyroUseState[i];
	}

	for(i = 0;i<WHEEL_NUM;i++)
	{
		pBK->BK_Whl_Use[i] = pImpt->Whl_Use[i];
	}
	
	for(i = 0;i<MAG_NUM;i++)
	{
		pBK->BK_MagUseState[i] = pImpt->MagUseState[i];
	}
	
	for(i = 0;i<ASS_NUM;i++)
	{
		pBK->BK_AssUseState[i] = pImpt->AssUseState[i];
	}

	for(i = 0;i<MT_NUM;i++)
	{
		pBK->BK_MTUseStatus[i] = pImpt->MTUseStatus[i];
	}
	
	pBK->BK_PPUUseStatus= 0;
	if (POSE_OK == pImpt->PPUUseStatus)
	{
		pBK->BK_PPUUseStatus= pBK->BK_PPUUseStatus | 0x05;
	}
	else
	{
		pBK->BK_PPUUseStatus= pBK->BK_PPUUseStatus & 0xF0;
	}

	if (POSE_OK == pImpt->PPUSafeStatus)
	{
		pBK->BK_PPUUseStatus= pBK->BK_PPUUseStatus | 0x50;
	}
	else
	{
		pBK->BK_PPUUseStatus= pBK->BK_PPUUseStatus & 0x0F;
	}
	
	for(i = 0;i<MT_NUM;i++)
	{
		pBK->BK_MTUseStatus[i]= pImpt->MTUseStatus[i];
	}

	for (i = 0;i<3;i++)
	{
		pBK->BK_Gyro_ComRESW[i] = tmpConst->AttCmdFlashPara.Gyro_ComRESW[i];
	}

	for (i = 0;i<3;i++)
	{
		pBK->BK_Mag_ComRESW[i] = tmpConst->AttCmdFlashPara.Mag_ComRESW[i];
	}

	for (i = 0;i<STAR_NUM;i++)
	{
		pBK->BK_ssPrior[i] = tmpConst->SSUsePrior[i];
	}
	
	for (i = 0;i<GYRO_NUM;i++)
	{
		pBK->BK_GyroPrior[i] = tmpConst->GyroUsePrior[i];
	}
	
	for (i = 0;i<STAR_NUM;i++)
	{
		pBK->BK_ss_Diag[i] = pREcheck->ss_Diag[i];
	}

	for (i = 0;i<MAG_NUM;i++)
	{
		pBK->BK_Mag_Diag[i] = pREcheck->Mag_Diag[i];
	}

	for (i = 0;i<GYRO_NUM;i++)
	{
		pBK->BK_Gyro_Diag[i] = pREcheck->Gyro_Diag[i];
	}

	for (i = 0;i<WHEEL_NUM;i++)
	{
		pBK->BK_Whl_Diag[i]= pREcheck->Whl_Diag[i];
	}

	for (i = 0;i<STAR_NUM;i++)
	{
		pBK->BK_AllowssONOFF[i]= tmpConst->AllowssONOFF[i];
	}

	for (i = 0;i<GYRO_NUM;i++)
	{
		pBK->BK_AllowGyroONOFF[i]= tmpConst->AllowGyroONOFF[i];
	}

	for (i = 0;i<MAG_NUM;i++)
	{
		pBK->BK_AllowMagONOFF[i]= tmpConst->AllowMagONOFF[i];
	}

	for (i = 0;i<WHEEL_NUM;i++)
	{
		pBK->BK_AllowWhlONOFF[i]= tmpConst->AllowWhlONOFF[i];
	}

	pBK->BK_AllowPPUONOFF= tmpConst->AllowPPUONOFF;

	pBK->BK_Allow_Sensor_CThr	= tmpConst->Allow_Sensor_CThr;
	pBK->BK_AllowAttLoseDiagFlg	= tmpConst->AllowAttLoseDiagFlg;
	pBK->BK_AllowAttExDiagFlg	= tmpConst->AllowAttExDiagFlg;
	pBK->BK_AllowAttStaDiagFlg	= tmpConst->AllowAttStaDiagFlg;
}


/**************************************
**说明：数据备份
***************************************/
void ZKDoActDataTer(void)
{
    UINT8 *tmpAddr =  0X00;
	AttBKPara_t *tmpPCInfo = NULL;
	sAttPriData *tmpAtt = NULL;
	tmpAtt=(sAttPriData *)ATTCLT_DATA1_ADDR;
	if(NULL == tmpAtt)
	{
		return;
	}
	tmpPCInfo =&tmpAtt->AttBKPara;
    AttBKPara_t	*tmpBKStr = NULL;
    tmpAddr = (UINT8 *)(ST_IMPDATA_ADDR + ST_IMPDATA_HEAD + ST_IMPDATA_ATTMNG_OFFSET * 64);	/*电源备份数据存储区域，第9块*/
	if(tmpAddr==NULL)
	return;    
    tmpBKStr = (AttBKPara_t *)tmpAddr;
 
    /*保存数据:备份数据结构与能源结构体前几个成员保持一致，直接数据拷贝*/
	//memset(((UINT8 *)tmpBKStr + sizeof(sSaveDataHead)), 0, 64*ST_IMPDATA_ATTMNG_BLOCKS);
    //memcpy(((UINT8 *)tmpBKStr + sizeof(sSaveDataHead)),(UINT8 *)tmpPCInfo,(sizeof(AttBKPara_t)-sizeof(sSaveDataHead) - 4));
	memcpy(((UINT8 *)tmpBKStr),(UINT8 *)tmpPCInfo,(sizeof(AttBKPara_t)));

    /*设定校验*/
    //tmpBKStr->sBKHead.iDataLength = 64*ST_IMPDATA_ATTMNG_BLOCKS - sizeof(sSaveDataHead);
    tmpBKStr->sBKHead.iDataLength = sizeof(AttBKPara_t) - sizeof(sSaveDataHead);
	tmpBKStr->sBKHead.iDataType = BACKUP_TYPE_ATTFIFO;
    tmpBKStr->iVldFlag = 0x55555555;
    tmpBKStr->sBKHead.iDataCheck = DoGetCheckSum(tmpAddr + sizeof(sSaveDataHead), tmpBKStr->sBKHead.iDataLength );

    /*设置更新标志*/
    tmpAddr = (UINT8 *)ST_IMPDATA_ADDR;
    tmpAddr[ST_IMPDATA_ATTMNG_OFFSET] = 0x55;
}


/***********************************************
说明：备份数据恢复
输入：
输出：
***********************************************/
void	ZKCtrlReinitBK(void)
{
	UINT8	i = 0;
	//UINT8   bChkOK = POSE_NO;
	UINT8	*tmpAddr =  0X00;
	UINT16  *tmpData16 = NULL;
	UINT16	tmpDA1 = 0U;
	TYPE_CAL fData1 = 0.0F;
	
	sAttPriData *tmpAtt = NULL;
	AttCtrlConst_t *tmpConst = NULL;
	AttBKPara_t	*tmpBKStr = NULL;
	//sTaskMngDataRecord   *tmpTaskMngDataRcd = NULL;
	sDevInfo	*tmpDevInfo = NULL;
	
	//tmpTaskMngDataRcd = (sTaskMngDataRecord *)ST_TASKMNG_ADDR;
	tmpAtt = (sAttPriData *)ATTCLT_DATA1_ADDR;
	tmpConst = (AttCtrlConst_t *)ATTCLT_DATA2_ADDR;

	if((NULL == tmpAtt) || (NULL == tmpConst))
	{
		return;
	}
	
	/*获取双机FIFO数据地址*/
	tmpAddr = (UINT8 *)(ST_IMPDATA_ADDR + ST_IMPDATA_HEAD + ST_IMPDATA_ATTMNG_OFFSET * 64);
	tmpBKStr = (AttBKPara_t *)tmpAddr;
	
	/*对关键变量进行三取二，每周期都获取*/
	ATTGetImportDataFromBuff();
	
	/*首次卫星加电操作*/
	ZKDptPowerOnPrc();
	
	/*做重新初始化动作*/
	if(0x55U == m_pZKTaskInfo->iReInit)
	{
		m_pZKTaskInfo->iReInit= 0;
		
		tmpAtt->sModePara.ReDataBK = POSE_NO;
				
		/*获取本地FLASH 飞轮ID的装订参数*/
		ZKREFlashBK();

		/*重启/切机/复位 飞轮转速电流给0*/
		SetWheel(1,0,WHL_CMD_CODE_CURR);
		SetWheel(2,0,WHL_CMD_CODE_CURR);
		SetWheel(3,0,WHL_CMD_CODE_CURR);
		SetWheel(4,0,WHL_CMD_CODE_CURR);

		/*校验备份区数据有效性，若校验一次无效，再校验一次*/
		if(DoCheckSaveData(tmpAddr, 64*ST_IMPDATA_ATTMNG_BLOCKS) && (0x55555555 == tmpBKStr->iVldFlag)&&(BACKUP_TYPE_ATTFIFO == tmpBKStr->sBKHead.iDataType ))
		{
			tmpAtt->sModePara.ReDataBK= POSE_OK;
		}
		else if(DoCheckSaveData(tmpAddr, 64*ST_IMPDATA_ATTMNG_BLOCKS) && (0x55555555 == tmpBKStr->iVldFlag)&&(BACKUP_TYPE_ATTFIFO == tmpBKStr->sBKHead.iDataType ))
		{	
			tmpAtt->sModePara.ReDataBK= POSE_OK;
		}
		else
		{
			/*两次数据校验均无效，数据认为数据恢复无效；若帆板展开进入-速率阻尼，未展开进入-碰撞规避*/
			tmpDevInfo = GETDEVINFO(DEV_NO_AD);
			tmpData16 = (UINT16 *)(tmpDevInfo->cDevYCBuffer + INFO_ADDR_OFF);
			tmpDA1	 =	*(tmpData16 + SW47 - 1);	/*太阳翼展开机构展开到位正线*/
			fData1	 =	0.002442F * tmpDA1 - 5.0F;     /*(idata * 10.0 / 4095 - 5)*/
			
			if(POSE_ABSF(fData1) < 0.1)//0.1V以下
			{
				/*展开*/
				ZKModDoSet(ATTMOD_RATEDMP);
			}
			else
			{
				/*未展开*/
				ZKModDoSet(ATTMOD_NOCOLL);
			}
			return;
		}
		if (POSE_OK == tmpAtt->sModePara.ReDataBK)
		{
			/*数据校验通过，进行数据恢复*/
			tmpAtt->sModePara.WorkMode = tmpBKStr->BK_WorkMode;
			tmpConst->AttCmdFlashPara.WorkModeChangeAuto= tmpBKStr->BK_WorkModeChangeAuto;
		
			for(i = 0;i<STAR_NUM;i++)
			{
				tmpAtt->sErrCtlPara.SS_err[i]= tmpBKStr->BK_SS_err[i];
				tmpConst->SSUsePrior[i]=tmpBKStr->BK_ssPrior[i];
				tmpAtt->sErrCtlPara.ss_Diag[i]= tmpBKStr->BK_ss_Diag[i];
				tmpConst->AllowssONOFF[i]= tmpBKStr->BK_AllowssONOFF[i];
				tmpAtt->sIMPTPara.SSUseState[i]= tmpBKStr->BK_SSUseState[i];
			}
		
			for(i = 0;i<MAG_NUM;i++)
			{
				tmpAtt->sIMPTPara.MagUseState[i]= tmpBKStr->BK_MagUseState[i];
				tmpAtt->sErrCtlPara.Mag_err[i]= tmpBKStr->BK_Mag_err[i];
				tmpAtt->sErrCtlPara.Mag_Diag[i]= tmpBKStr->BK_Mag_Diag[i];
				tmpConst->AllowMagONOFF[i]= tmpBKStr->BK_AllowMagONOFF[i];
				tmpConst->AttCmdFlashPara.Mag_ComRESW[i]=tmpBKStr->BK_Mag_ComRESW[i];
			}
		
			for(i = 0;i<GYRO_NUM;i++)
			{
				tmpAtt->sErrCtlPara.Gyro_err[i]= tmpBKStr->BK_Gyro_err[i];
				tmpAtt->sIMPTPara.GyroUseState[i]= tmpBKStr->BK_GyroUseState[i];
				tmpConst->AttCmdFlashPara.Gyro_ComRESW[i]=tmpBKStr->BK_Gyro_ComRESW[i];
				tmpConst->GyroUsePrior[i]=tmpBKStr->BK_GyroPrior[i];
				tmpAtt->sErrCtlPara.Gyro_Diag[i]= tmpBKStr->BK_Gyro_Diag[i];
				tmpConst->AllowGyroONOFF[i]= tmpBKStr->BK_AllowGyroONOFF[i];
			}
		
			for(i = 0;i<WHEEL_NUM;i++)
			{
				tmpAtt->sErrCtlPara.Whl_Err[i]= tmpBKStr->BK_Whl_Err[i];
				tmpAtt->sIMPTPara.Whl_Use[i]= tmpBKStr->BK_Whl_Use[i];
				tmpAtt->sErrCtlPara.Whl_Diag[i]= tmpBKStr->BK_Whl_Diag[i];
				tmpConst->AllowWhlONOFF[i]= tmpBKStr->BK_AllowWhlONOFF[i];
			}
		
			tmpAtt->sErrCtlPara.PPU_Err= tmpBKStr->BK_PPU_Err;
		
			for(i = 0;i<ASS_NUM;i++)
			{
				tmpAtt->sIMPTPara.AssUseState[i]= tmpBKStr->BK_AssUseState[i];
			}

			for(i = 0;i<MT_NUM;i++)
			{
				tmpAtt->sIMPTPara.MTUseStatus[i]= tmpBKStr->BK_MTUseStatus[i];
				tmpAtt->sIMPTPara.MTUseStatus[i]= tmpBKStr->BK_MTUseStatus[i];
			}

			if (0x05 == (tmpBKStr->BK_PPUUseStatus & 0x0F))
			{
				tmpAtt->sIMPTPara.PPUUseStatus= POSE_OK;
			}
			else
			{
				tmpAtt->sIMPTPara.PPUUseStatus= POSE_NO;
			}

			if (0x50 == (tmpBKStr->BK_PPUUseStatus & 0xF0))
			{
				tmpAtt->sIMPTPara.PPUSafeStatus= POSE_OK;
			}
			else
			{
				tmpAtt->sIMPTPara.PPUSafeStatus= POSE_NO;
			}

			tmpConst->AllowPPUONOFF= tmpBKStr->BK_AllowPPUONOFF;
			tmpConst->Allow_Sensor_CThr= tmpBKStr->BK_Allow_Sensor_CThr;
			tmpConst->AllowAttLoseDiagFlg= tmpBKStr->BK_AllowAttLoseDiagFlg;
			tmpConst->AllowAttExDiagFlg= tmpBKStr->BK_AllowAttExDiagFlg;
			tmpConst->AllowAttStaDiagFlg= tmpBKStr->BK_AllowAttStaDiagFlg;
			if (ATTMOD_BREAKPRE == tmpAtt->sModePara.WorkMode)
			{
				tmpAtt->sModePara.WorkMode = ATTMOD_NOCOLL;
			}
			/*判断恢复后的工作模式，以及根据相应模式进行处理*/
			ZKReModBK();
		}
	
		///*重启、切机、复位恢复关键参数后，写入三取二数据存储区*/
		//ATTImportDataBackup();
	}
}

/***********************************************
说明：数据备份
输入：
输出：
***********************************************/
void	ZKCtrlDataBackUp(void)
{
	if(POSE_OK != m_pZKTaskInfo->iReInit)
	{
		ZKDataBackUp();
		ZKDoActDataTer();
	}
}

/************************************************Flash********************************************************************/
/***********************************************
说明：从Flash恢复数据
注意:
***********************************************/
void ATTRestoreFromFlash(void)
{
	AttBackupFlash_t  AttBackupFlashPara;
	UINT8 *tmpAddr = (UINT8 *)(ST_FIXDATA_ATTSADA_ADDR);
	AttBackupFlash_t *tmpBackup = (AttBackupFlash_t *)(ST_FIXDATA_ATTSADA_ADDR);	/*固定数据区*/
	sAttPriData *tmpAtt = NULL;
	AttCtrlConst_t *tmpConst = NULL;
	AttCmdFlash_t *PFlash = NULL;

	tmpAtt=(sAttPriData *)ATTCLT_DATA1_ADDR;	
	tmpConst=(AttCtrlConst_t *)ATTCLT_DATA2_ADDR;
	PFlash = &tmpConst->AttCmdFlashPara;

	if ( NULL == tmpBackup || NULL == tmpConst  || NULL == tmpAtt)
	{
		return;
	}
	
	/* 若固定数据区数据（星务从测控单机Flash备份过来的数据）有效 */
	if ( BACKUP_TYPE_ATTFLASH == tmpBackup->sBKHead.iDataType && TRUE == DoCheckSaveData(tmpAddr, tmpBackup->sBKHead.iDataLength) && 0x55555555 == tmpBackup->iVldFlag )
	{
		FixDataStorFlashByType(FIXDATA_TYPE_ATTSADA, (UINT8*)tmpAddr, sizeof(AttBackupFlash_t));		/* 将固定数据区数据存到本地Flash */
	}
	/* 若测控单机数据无效，则从本地Flash读取数据到固定数据区 */
	else
	{
		/* 读取Flash备份数据 */
		memset((UINT8 *)tmpAddr, 0, ST_FIXDATA_ATTSADA_SIZE);
		FixDataLoadFlashByType(FIXDATA_TYPE_ATTSADA, (UINT8 *)tmpAddr, sizeof(AttBackupFlash_t));

		/* 检查类型和长度，若非法则不从Flash恢复 */
		if ( BACKUP_TYPE_ATTFLASH != tmpBackup->sBKHead.iDataType || 0 == tmpBackup->sBKHead.iDataLength || 0xFFFFFFFF == tmpBackup->sBKHead.iDataLength )
		{
			return;
		}

		/* 检查和校验和有效标志位，若非法则不从Flash恢复 */
		if ( TRUE != DoCheckSaveData(tmpAddr, tmpBackup->sBKHead.iDataLength) || 0x55555555 != tmpBackup->iVldFlag )
		{
			return;
		}
	}
	memcpy((UINT8 *)(&AttBackupFlashPara),((UINT8 *)tmpBackup ),sizeof(AttBackupFlash_t));
	//姿控Flash数据读取	
	memcpy((UINT8 *)PFlash,((UINT8 *)(&AttBackupFlashPara.AttFlashPara) ),sizeof(AttCmdFlash_t));
	//帆板Flash数据读取
	memcpy((UINT8 *)(&tmpAtt->ATSFlashPara),((UINT8 *)(&AttBackupFlashPara.SadaFlashPara) ),sizeof(SadaCmdFlash_t));
	
}


/***********************************************
说明：备份到Flash
注意:
***********************************************/
void ATTBackupToFlash(void)
{
	AttBackupFlash_t  AttBackupFlashPara;
	UINT8 *tmpAddr = (UINT8 *)(ST_FIXDATA_ATTSADA_ADDR);
	AttBackupFlash_t *tmpBackup = (AttBackupFlash_t *)(ST_FIXDATA_ATTSADA_ADDR);	/*固定数据区*/
	sAttPriData *tmpAtt = NULL;
	AttCtrlConst_t *tmpConst = NULL;
	AttCmdFlash_t *PFlash = NULL;
	tmpConst=(AttCtrlConst_t *)ATTCLT_DATA2_ADDR;
	tmpAtt=(sAttPriData *)ATTCLT_DATA1_ADDR;
	PFlash = &tmpConst->AttCmdFlashPara;
	
	//QSPI轮询状态(0x55:擦除使能)执行FLASH数据备份写操作
	//QspiFlashWriteProcess(FIXDATA_TYPE_ATTSADA, sizeof(AttBackupFlash_t));
	
	if ( NULL == tmpBackup || NULL == tmpConst || NULL == tmpAtt )
	{
		return;
	}
	
	/* 若固定数据区没有更新，则直接退出 */
	if ( POSE_OK != tmpAtt->sModePara.ATTFlashSwitch )
	{
		return;
	}
	
	//姿控Flash数据写
	memcpy((UINT8 *)(&AttBackupFlashPara.AttFlashPara),((UINT8 *)PFlash),sizeof(AttCmdFlash_t));
	//SADA数据写
	memcpy((UINT8 *)(&AttBackupFlashPara.SadaFlashPara),(UINT8 *)(&tmpAtt->ATSFlashPara),sizeof(SadaCmdFlash_t));	
	//写入Flash缓存		
	memcpy((UINT8 *)tmpBackup,((UINT8 *)(&AttBackupFlashPara) ),sizeof(AttBackupFlash_t));	

	/* 设定有效标志位 */
	tmpBackup->iVldFlag = 0x55555555;
	
	/* 设定Flash头的长度、类型、校验和 */
	tmpBackup->sBKHead.iDataLength = sizeof(AttBackupFlash_t) - sizeof(sSaveDataHead);
	tmpBackup->sBKHead.iDataType = (UINT16)BACKUP_TYPE_ATTFLASH;
	tmpBackup->sBKHead.iDataCheck = DoGetCheckSum(tmpAddr+sizeof(sSaveDataHead), tmpBackup->sBKHead.iDataLength);
	
	/* 写入Flash */
	FixDataStorFlashByType(FIXDATA_TYPE_ATTSADA, (UINT8*)tmpAddr, sizeof(AttBackupFlash_t));
	
	/* 清除更新标志位 */
	tmpAtt->sModePara.ATTFlashSwitch = POSE_NO;
}


/***********************************************
说明：姿控的动作前准备，获取轨道数据
注意:	
***********************************************/
void ZKPreAction(void)
{
	UINT8		i = 0x00;
	UINT16 *tmpAddr = (UINT16 *)MAG_BASE_ADDR;

	sAttPriData *tmpAtt = NULL;
	sAttOrbitGetPara_t *pOrbit = NULL;
	OrbitPriData_t *tmpOrbit = NULL;		
	sAttModPara_t *pWMod = NULL;
	MtPara_t	*pMt = NULL;
	sSadaCtrlInfo* tmpSadaCtlInfo = (sSadaCtrlInfo *)SADACTR_BASE_ADDR;
	tmpAtt=(sAttPriData *)ATTCLT_DATA1_ADDR;
	if ((NULL == tmpSadaCtlInfo) || (NULL == tmpAtt ))
	{
		return;
	}
	pOrbit = &tmpAtt->sOrbitPara;
	pWMod =&tmpAtt->sModePara;	
	pMt=&tmpAtt->sPerPara.MtPara;
	
	/*获取轨道数据*/
	tmpOrbit = (OrbitPriData_t *)ORBIT_BASE_ADDR;
	for(i = 0; i< 3; ++i)
	{	
		pOrbit->JPos[i] = (TYPE_CAL)tmpOrbit->sPoseUseOrbit.Rj[i];
		pOrbit->JVel[i] = (TYPE_CAL)tmpOrbit->sPoseUseOrbit.Vj[i];
	}
	pOrbit->GAST = (TYPE_CAL)tmpOrbit->sPoseUseOrbit.GAST;
	pOrbit->MJC = (TYPE_CAL)tmpOrbit->sPoseUseOrbit.MJC;
	pOrbit->MJCLv = tmpOrbit->sPoseUseOrbit.MJCLv;
	pOrbit->OrbitVld = tmpOrbit->sPoseUseOrbit.ObtTZKVld;
	
	//获取帆板数据
	pWMod->WModSadaOpenPre= pWMod->WModSadaOpen;
	pWMod->WModSadaOpen=tmpSadaCtlInfo->sSadaDataUP.SadaOpenFlag; //帆板展开信号
	pMt->MTStatus = 0xFF & ReadReg(tmpAddr,MAG_REG_SATUS);
	//单机加电状态量获取
	ZKPowerState();
}


/***********************************************
说明：轨道控制模块，轨控主函数.
输入：上注轨控数据，当前模式
输出：PPU开关
***********************************************/
void    ZKOCOrbitCtl(void)
{
	UINT16		tmpiDataCheck = 0;		/*数据校验和*/	
	UINT8		cmdDataBuff[50] = {0};
	UINT32		SatTime[2] ={0,0};	
	UINT8 PPUOn[8]	= {0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
	UINT8 PPUOff[8]	= {0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
	PPUPara_t *PPPU = NULL;
	
	sTaskInfo* tmpTaskInfo = NULL;
	sAttPriData *tmpAtt = NULL;
	sAttOrbitCtlData_t *tmpOrbCmd = NULL;		
	sAttOrbitCtlInfo_t *pOrb = NULL;	
	sAttModPara_t *pWMod =NULL;	
	AttIMPTPara_t *pImpt = NULL;
		
	tmpAtt=(sAttPriData *)ATTCLT_DATA1_ADDR;
	tmpOrbCmd=(sAttOrbitCtlData_t *)ATTCLT_DATA3_ADDR;
	tmpTaskInfo = GetTaskInfoBT(TASK_ATTCTL);
	if ((NULL == tmpOrbCmd) || (NULL == tmpAtt))
	{
		return;
	}			
	pWMod=&tmpAtt->sModePara;
	pOrb=&tmpAtt->sOrbitInp;
	PPPU = &tmpAtt->sPerPara.PPUPara;
	pImpt= &tmpAtt->sIMPTPara;
	memset(cmdDataBuff, 0x00, 50);
	
	GetTime(SatTime);		//获取当前星上时
	
	if (POSE_OK != pOrb->OrbDataIn_OK)/*轨控数据包无效，直接退出*/
	{
		return;
	}

	if (pOrb->CurOrbCtrlPcak_ID >= 50)
	{
		DoSetInt32To8(ATT_CMDMODE_MODSUNCAP, cmdDataBuff);
		pOrb->CurOrbCtrlPcak_ID = 0;
		pOrb->CurOrbCtrlPcak_PreID =0xFF;
		pOrb->OrbCtrlPcak_ReceiveFlg[pOrb->CurOrbCtrlPcak_ID]= 0x00;
		PPPU->PPUT_FIR_Cnt = 0;
		pOrb->OrbDataIn_OK = POSE_NO;
		if(CheckBlockRing(&tmpTaskInfo->sCmdBuffer, tmpTaskInfo->sCmdDataBuff, MOD_REQ_MAXLEN, MOD_MAX_REQUEST))
		{
			/* 在姿控的指令处理中 进行 ZKModDoSet(ATT_CMDMODE_MODSUNCAP);*/
			BlockRingAdd(&tmpTaskInfo->sCmdBuffer, cmdDataBuff, TRUE);
		}
		return;
	}
	
	//轨道控制数据选择
	if (POSE_OK == pOrb->OrbDataIn_OK)
	{
		if  ((pOrb->CurOrbCtrlPcak_ID == (tmpOrbCmd->OrbCtrlPack[pOrb->CurOrbCtrlPcak_ID].OrbCtrlPcak_ID -1))&&(pOrb->CurOrbCtrlPcak_PreID != pOrb->CurOrbCtrlPcak_ID))
		{
			pOrb->CurOrbCtrlPcak_PreID = pOrb->CurOrbCtrlPcak_ID;
			tmpiDataCheck =DoGetCheckSum(&tmpOrbCmd->OrbCtrlPack[pOrb->CurOrbCtrlPcak_ID].OrbCtrlPcak_ID , 24);
			if ((pOrb->OrbCtrlPcak_ReceiveFlg[pOrb->CurOrbCtrlPcak_ID]== 0x55)&&(tmpiDataCheck == tmpOrbCmd->OrbCtrlPack[pOrb->CurOrbCtrlPcak_ID].OrbDateSum))
			{
				memcpy(&(pOrb->OrbCtrlPackCur), &(tmpOrbCmd->OrbCtrlPack[pOrb->CurOrbCtrlPcak_ID]), sizeof(AttOrbCtrlPara_t));
			}
			else
			{
				DoSetInt32To8(ATT_CMDMODE_MODSUNCAP, cmdDataBuff);
				pOrb->CurOrbCtrlPcak_ID = 0;
				pOrb->CurOrbCtrlPcak_PreID =0xFF;
				pOrb->OrbCtrlPcak_ReceiveFlg[pOrb->CurOrbCtrlPcak_ID]= 0x00;
				PPPU->PPUT_FIR_Cnt = 0;
				pOrb->OrbDataIn_OK = POSE_NO;
				if(CheckBlockRing(&tmpTaskInfo->sCmdBuffer, tmpTaskInfo->sCmdDataBuff, MOD_REQ_MAXLEN, MOD_MAX_REQUEST))
				{
					/* 在姿控的指令处理中 进行 ZKModDoSet(ATT_CMDMODE_MODSUNCAP);*/
					BlockRingAdd(&tmpTaskInfo->sCmdBuffer, cmdDataBuff, TRUE);
				}
				return;
			}
		}
	}
	
	if((POSE_OK == pOrb->OrbDataIn_OK)
		&&(0x55 == pOrb->OrbCtrlPcak_ReceiveFlg[pOrb->CurOrbCtrlPcak_ID])
		)
	{
		if(((ATTMOD_WhlTOSUN == pWMod->WorkMode) ||(ATTMOD_WHEELTOEARTH == pWMod->WorkMode))
			&&(SatTime[0]>=pOrb->OrbCtrlPackCur.OrbAttAjustTime)
			&&(SatTime[0]<pOrb->OrbCtrlPackCur.OrbCtrl_StartTime)
			)
		{	
			 DoSetInt32To8(ATT_WORKMODE_ORBITCTLPRE, cmdDataBuff);
			 if(CheckBlockRing(&tmpTaskInfo->sCmdBuffer, tmpTaskInfo->sCmdDataBuff, MOD_REQ_MAXLEN, MOD_MAX_REQUEST)) 
			 {
				 /* 在姿控的指令处理中 进行 ZKModDoSet(ATTMOD_ATTAJUSTPRE);*/
				 BlockRingAdd(&tmpTaskInfo->sCmdBuffer, cmdDataBuff, TRUE);     
			 }
		}
		else if((ATTMOD_ATTAJUSTPRE == pWMod->WorkMode)
			&&((SatTime[0]>=pOrb->OrbCtrlPackCur.OrbCtrl_StartTime)
			&&(SatTime[0]<= (pOrb->OrbCtrlPackCur.OrbCtrl_StartTime+pOrb->OrbCtrlPackCur.OrbCtrl_TimeLength)))
			)
		{
			DoSetInt32To8(ATT_WORKMODE_ORBITCTL, cmdDataBuff);
			if(CheckBlockRing(&tmpTaskInfo->sCmdBuffer, tmpTaskInfo->sCmdDataBuff, MOD_REQ_MAXLEN, MOD_MAX_REQUEST))
			{
				/* 在姿控的指令处理中 进行 ZKModDoSet(ATTMOD_ORBITCTL);*/
				BlockRingAdd(&tmpTaskInfo->sCmdBuffer, cmdDataBuff, TRUE);
				if (POSE_OK == pImpt->PPUUseStatus)
				{
					//PPU开机指令
					dev_can_write(DEV_NO_CAN0,PPUOn,8);
					PPPU->PPUOUT_Sta = POSE_OK;
					tmpAtt->sCtlPara.ZK_Ctrl_Reserver111 = POSE_NO;	
				}
			}
		}
		else if((ATTMOD_ORBITCTL == pWMod->WorkMode)
		&&((SatTime[0]>=(pOrb->OrbCtrlPackCur.OrbCtrl_StartTime+pOrb->OrbCtrlPackCur.OrbCtrl_TimeLength))&&
		(SatTime[0]<= (pOrb->OrbCtrlPackCur.OrbCtrl_StartTime+pOrb->OrbCtrlPackCur.OrbCtrl_TimeLength + 1))))
		{
			/*进入到这里，说明一组轨控流程正常退出*/
			switch(pOrb->OrbCtrlPackCur.OrbCtrl_Mod)
			{
				case	0x11:
					DoSetInt32To8(ATT_CMDMODE_WHEELTOEARTH, cmdDataBuff);
					pOrb->CurOrbCtrlPcak_ID ++;
					/*设置下一拍关PPU电源*/
					PPPU->PPU_OrbitCtl_Quit_Err_Flag = POSE_OK;/*正常退出轨控标志使能*/
					PPPU->PPU_OrbitCtl_Quit_Err_Cnt = 0;/*退出轨控后节拍计数清零*/
			
					PPPU->PPU_OrbitCtl_Quit_OK_Flag = POSE_OK;/*正常退出轨控标志使能*/
					PPPU->PPU_OrbitCtl_Quit_OK_Cnt = 0;/*退出轨控后节拍计数清零*/
				break;
				case	0x22:
					DoSetInt32To8(ATT_CMDMODE_WhlTOSUN, cmdDataBuff);
					pOrb->CurOrbCtrlPcak_ID ++;
					/*设置下一拍关PPU电源*/
					PPPU->PPU_OrbitCtl_Quit_Err_Flag = POSE_OK;/*正常退出轨控标志使能*/
					PPPU->PPU_OrbitCtl_Quit_Err_Cnt = 0;/*退出轨控后节拍计数清零*/
			
					PPPU->PPU_OrbitCtl_Quit_OK_Flag = POSE_OK;/*正常退出轨控标志使能*/
					PPPU->PPU_OrbitCtl_Quit_OK_Cnt = 0;/*退出轨控后节拍计数清零*/
				break;
				case	0x33:
					DoSetInt32To8(ATT_WORKMODE_ORBITCTLPRE, cmdDataBuff);
					pOrb->CurOrbCtrlPcak_ID ++;
					/*设置下一拍关PPU电源*/
					PPPU->PPU_OrbitCtl_Quit_Err_Flag = POSE_OK;/*正常退出轨控标志使能*/
					PPPU->PPU_OrbitCtl_Quit_Err_Cnt = 0;/*退出轨控后节拍计数清零*/
			
					PPPU->PPU_OrbitCtl_Quit_OK_Flag = POSE_OK;/*正常退出轨控标志使能*/
					PPPU->PPU_OrbitCtl_Quit_OK_Cnt = 0;/*退出轨控后节拍计数清零*/
				break;
				case	0x44:
					DoSetInt32To8(ATT_CMDMODE_ONLTOEARTH, cmdDataBuff);
					pOrb->CurOrbCtrlPcak_ID = 0;
					pOrb->CurOrbCtrlPcak_PreID =0xFF;
					pOrb->OrbCtrlPcak_ReceiveFlg[pOrb->CurOrbCtrlPcak_ID]= 0x00;
					PPPU->PPUT_FIR_Cnt = 0;
					pOrb->OrbDataIn_OK = POSE_NO;				
					/*设置下一拍关PPU电源*/
					PPPU->PPU_OrbitCtl_Quit_Err_Flag = POSE_OK;/*正常退出轨控标志使能*/
					PPPU->PPU_OrbitCtl_Quit_Err_Cnt = 0;/*退出轨控后节拍计数清零*/
							
					PPPU->PPU_OrbitCtl_Quit_OK_Flag = POSE_NO;/*正常退出轨控标志使能*/
					PPPU->PPU_OrbitCtl_Quit_OK_Cnt = 0;/*退出轨控后节拍计数清零*/
				break;
				case	0x55:
					DoSetInt32To8(ATT_CMDMODE_WhlTOSUN, cmdDataBuff);
					pOrb->CurOrbCtrlPcak_ID = 0;
					pOrb->CurOrbCtrlPcak_PreID =0xFF;
					pOrb->OrbCtrlPcak_ReceiveFlg[pOrb->CurOrbCtrlPcak_ID]= 0x00;
					PPPU->PPUT_FIR_Cnt = 0;
					pOrb->OrbDataIn_OK = POSE_NO;

					/*设置下一拍关PPU电源*/
					PPPU->PPU_OrbitCtl_Quit_Err_Flag = POSE_OK;/*正常退出轨控标志使能*/
					PPPU->PPU_OrbitCtl_Quit_Err_Cnt = 0;/*退出轨控后节拍计数清零*/
					
					PPPU->PPU_OrbitCtl_Quit_OK_Flag = POSE_NO;/*正常退出轨控标志使能*/
					PPPU->PPU_OrbitCtl_Quit_OK_Cnt = 0;/*退出轨控后节拍计数清零*/
				break;
				default:
					DoSetInt32To8(ATT_CMDMODE_MODSUNCAP, cmdDataBuff);
					pOrb->CurOrbCtrlPcak_ID = 0;
					pOrb->CurOrbCtrlPcak_PreID =0xFF;
					pOrb->OrbCtrlPcak_ReceiveFlg[pOrb->CurOrbCtrlPcak_ID]= 0x00;
					PPPU->PPUT_FIR_Cnt = 0;
					pOrb->OrbDataIn_OK = POSE_NO;

					/*设置下一拍关PPU电源*/
					PPPU->PPU_OrbitCtl_Quit_Err_Flag = POSE_OK;/*正常退出轨控标志使能*/
					PPPU->PPU_OrbitCtl_Quit_Err_Cnt = 0;/*退出轨控后节拍计数清零*/
					
					PPPU->PPU_OrbitCtl_Quit_OK_Flag = POSE_NO;/*正常退出轨控标志使能*/
					PPPU->PPU_OrbitCtl_Quit_OK_Cnt = 0;/*退出轨控后节拍计数清零*/
				break;
			}
			
			if(CheckBlockRing(&tmpTaskInfo->sCmdBuffer, tmpTaskInfo->sCmdDataBuff, MOD_REQ_MAXLEN, MOD_MAX_REQUEST))
			{
				/* 在姿控的指令处理中 ;*/
				BlockRingAdd(&tmpTaskInfo->sCmdBuffer, cmdDataBuff, TRUE);
				
			}
			
			PPPU->PPUOUT_Sta = POSE_NO;/*电推指令开关标志为关*/
			tmpAtt->sCtlPara.ZK_Ctrl_Reserver111 = POSE_NO;	
			//PPU关机指令
			dev_can_write(DEV_NO_CAN0, PPUOff, 8);/*轨控正常退出，电推关机操作，需要5秒后给电推供电*/
		}
	}

}

/***********************************************
说明：姿控的动作前准备，获取目标定向数据
注意:
***********************************************/
void ZKOCTarCtl(void)
{
	UINT16		tmpiDataCheck =0;		/*数据校验和*/
	UINT8		cmdDataBuff[50] = {0};
	UINT32		SatTime[2] ={0,0};
	sAttPriData *tmpAtt = NULL;
	AttCtrlConst_t *tmpConst = NULL;	
	sAttTARCCtlData_t *tmpTARCmd = NULL;
	sAttTARCCtlInfo_t *pTARC = NULL;	
	sAttModPara_t *pWMod =NULL;		
	sTaskInfo* tmpTaskInfo = NULL;
	
	tmpAtt=(sAttPriData *)ATTCLT_DATA1_ADDR;
	tmpConst=(AttCtrlConst_t *)ATTCLT_DATA2_ADDR;	
	tmpTARCmd=(sAttTARCCtlData_t *)ATTCLT_DATA6_ADDR;
	if (NULL == tmpTARCmd || NULL == tmpAtt  || NULL == tmpConst)
	{
		return;
	}	
	
	tmpTaskInfo = GetTaskInfoBT(TASK_ATTCTL);
	
	pWMod=&tmpAtt->sModePara;
	pTARC=&tmpAtt->sTARCInp;
	
	if (POSE_OK != pTARC->TARDataIn_OK)/*目标定向数据包无效，直接退出*/
	{
		return;
	}
	
	if (pTARC->CurTARCtrlPcak_ID >= 30)
	{
		pTARC->CurTARCtrlPcak_ID = 0;
		return;
	}
	
	memset(cmdDataBuff, 0x00, 50);
	
	GetTime(SatTime);		//获取当前星上时

	if (POSE_OK==pTARC->TARDataIn_OK)
	{
		if  ((pTARC->CurTARCtrlPcak_ID == (tmpTARCmd->TARCtrlPack[pTARC->CurTARCtrlPcak_ID].TARCtrlPcak_ID -1)) &&(pTARC->CurTARCtrlPcak_ID != pTARC->CurTARCtrlPcak_PreID))
		{
			pTARC->CurTARCtrlPcak_PreID = pTARC->CurTARCtrlPcak_ID;
			tmpiDataCheck=DoGetCheckSum(&(tmpTARCmd->TARCtrlPack[pTARC->CurTARCtrlPcak_ID].TARCtrlPcak_ID), 23);
			if ((pTARC->TARCtrlPcak_ReceiveFlg[pTARC->CurTARCtrlPcak_ID]== 0x55)&&(tmpiDataCheck == tmpTARCmd->TARCtrlPack[pTARC->CurTARCtrlPcak_ID].TARCtrlDateSum))
			{
				memcpy(&(pTARC->TARCtrlPackCur), &(tmpTARCmd->TARCtrlPack[pTARC->CurTARCtrlPcak_ID]), sizeof(sAttTARCCtlPara_t));
			}
			else
			{
				pTARC->TARCtrlPcak_ReceiveFlg[pTARC->CurTARCtrlPcak_ID] = 0x00;
				DoSetInt32To8(ATT_CMDMODE_ONLTOEARTH, cmdDataBuff);
				pTARC->CurTARCtrlPcak_ID=0;
				pTARC->CurTARCtrlPcak_PreID =0xFF;
				pTARC->TARDataIn_OK = POSE_NO;
				if(CheckBlockRing(&tmpTaskInfo->sCmdBuffer, tmpTaskInfo->sCmdDataBuff, MOD_REQ_MAXLEN, MOD_MAX_REQUEST))
				{
					BlockRingAdd(&tmpTaskInfo->sCmdBuffer, cmdDataBuff, TRUE);
				}
				return ;
			}
		}
	}

	if((POSE_OK == pTARC->TARDataIn_OK)
			&&(0x55 == pTARC->TARCtrlPcak_ReceiveFlg[pTARC->CurTARCtrlPcak_ID])
	)
	{
		if(((ATTMOD_WhlTOSUN == pWMod->WorkMode) ||(ATTMOD_WHEELTOEARTH == pWMod->WorkMode))
				&&(SatTime[0]>=pTARC->TARCtrlPackCur.TARCtrl_JustTime)
				&&(SatTime[0]<pTARC->TARCtrlPackCur.TARCtrl_StartTime)
		)
		{
			DoSetInt32To8(ATT_WORKMODE_ATTAJUST, cmdDataBuff);
			if(CheckBlockRing(&tmpTaskInfo->sCmdBuffer, tmpTaskInfo->sCmdDataBuff, MOD_REQ_MAXLEN, MOD_MAX_REQUEST))
			{
				/* 在姿控的指令处理中 进行 ZKModDoSet(ATTMOD_ATTAJUSTPRE);*/
				BlockRingAdd(&tmpTaskInfo->sCmdBuffer, cmdDataBuff, TRUE);
			}
		}
		else if((ATTMOD_ATTAJUST == pWMod->WorkMode)
				&&((SatTime[0]>=pTARC->TARCtrlPackCur.TARCtrl_StartTime)
				&&(SatTime[0]<= (pTARC->TARCtrlPackCur.TARCtrl_StartTime+pTARC->TARCtrlPackCur.TARCtrl_TimeLength)))
		)
		{
			DoSetInt32To8(ATT_WORKMODE_ONLTOTAR, cmdDataBuff);
			if(CheckBlockRing(&tmpTaskInfo->sCmdBuffer, tmpTaskInfo->sCmdDataBuff, MOD_REQ_MAXLEN, MOD_MAX_REQUEST))
			{
				/* 在姿控的指令处理中 进行 ZKModDoSet(ATTMOD_ORBITCTL);*/
				BlockRingAdd(&tmpTaskInfo->sCmdBuffer, cmdDataBuff, TRUE);
			}
		}
		else if((ATTMOD_ONLTOTAR == pWMod->WorkMode)
				&&((SatTime[0]>=(pTARC->TARCtrlPackCur.TARCtrl_StartTime+pTARC->TARCtrlPackCur.TARCtrl_TimeLength))&&
				(SatTime[0]<= (pTARC->TARCtrlPackCur.TARCtrl_StartTime+pTARC->TARCtrlPackCur.TARCtrl_TimeLength + 1))))
		{
			if (pTARC->CurTARCtrlPcak_ID < 29)
			{
				pTARC->CurTARCtrlPcak_ID ++;
				if(0 == tmpTARCmd->TARCtrlPack[pTARC->CurTARCtrlPcak_ID].TARCtrlPcak_ID)/*下一包ID为0，认为目标定向结束*/
				{
					pTARC->TARCtrlPcak_ReceiveFlg[pTARC->CurTARCtrlPcak_ID] = 0x00;
					DoSetInt32To8(ATT_CMDMODE_ONLTOEARTH, cmdDataBuff);
					pTARC->CurTARCtrlPcak_ID=0;
					pTARC->CurTARCtrlPcak_PreID =0xFF;
					pTARC->TARDataIn_OK = POSE_NO;
				}
				else
				{
					DoSetInt32To8(ATT_WORKMODE_ATTAJUST, cmdDataBuff);
				}
				
			}
			else
			{
				DoSetInt32To8(ATT_CMDMODE_ONLTOEARTH, cmdDataBuff);
				pTARC->CurTARCtrlPcak_ID=0;
				pTARC->CurTARCtrlPcak_PreID =0xFF;
				pTARC->TARCtrlPcak_ReceiveFlg[pTARC->CurTARCtrlPcak_ID]= 0x00;
				pTARC->TARDataIn_OK = POSE_NO;
			}
			
			if(CheckBlockRing(&tmpTaskInfo->sCmdBuffer, tmpTaskInfo->sCmdDataBuff, MOD_REQ_MAXLEN, MOD_MAX_REQUEST))
			{
				/* 在姿控的指令处理中 进行 ZKModDoSet(ATTMOD_ORBITCTL);*/
				BlockRingAdd(&tmpTaskInfo->sCmdBuffer, cmdDataBuff, TRUE);
			}
			
		}
	}
	
	if((POSE_OK == pTARC->TARDataIn_OK) && (ATTMOD_ONLTOTAR == pWMod->WorkMode))
	{
		/*判断当前时间，是否在目标定向时间段内*/
		if (!(
				(SatTime[0]>=(pTARC->TARCtrlPackCur.TARCtrl_StartTime-2)) &&
				(SatTime[0]<= (pTARC->TARCtrlPackCur.TARCtrl_StartTime + pTARC->TARCtrlPackCur.TARCtrl_TimeLength+2))
			))
		{
			/*不在的话退出,进入对地定向模式*/
			DoSetInt32To8(ATT_CMDMODE_ONLTOEARTH, cmdDataBuff);
			pTARC->CurTARCtrlPcak_ID=0;
			pTARC->CurTARCtrlPcak_PreID =0xFF;
			pTARC->TARCtrlPcak_ReceiveFlg[pTARC->CurTARCtrlPcak_ID]= 0x00;
			pTARC->TARDataIn_OK = POSE_NO;
			if(CheckBlockRing(&tmpTaskInfo->sCmdBuffer, tmpTaskInfo->sCmdDataBuff, MOD_REQ_MAXLEN, MOD_MAX_REQUEST))
			{
				/* 在姿控的指令处理中*/
				BlockRingAdd(&tmpTaskInfo->sCmdBuffer, cmdDataBuff, TRUE);
			}
			return;
		}
	}		
}

///***********************************************
//说明：最小模式单机加电
//注意: 每0.5秒调用一次
//***********************************************/
void ZKMiniPowerOn(void)
{
//	UINT8	i = 0;
	UINT8	*tmpAddr =  0X00;	
	sAttPriData *tmpAtt = NULL;
	AttCtrlConst_t *tmpConst = NULL;
//	AttBKPara_t	*tmpBKStr = NULL;
	tmpAtt = (sAttPriData *)ATTCLT_DATA1_ADDR;
	tmpConst = (AttCtrlConst_t *)ATTCLT_DATA2_ADDR;

	if((NULL == tmpAtt) || (NULL == tmpConst))
	{
		return;
	}
	
	/*获取双机FIFO数据地址*/
	tmpAddr = (UINT8 *)(ST_IMPDATA_ADDR + ST_IMPDATA_HEAD + ST_IMPDATA_ATTMNG_OFFSET * 64);
//	tmpBKStr = (AttBKPara_t *)tmpAddr;
	
	/*首次卫星加电操作*/
	ZKDptPowerOnPrc();

	/*做重新初始化动作*/
	if(POSE_OK == tmpAtt->sModePara.MiniDataSet)
	{
		m_pZKTaskInfo->iReInit= 0;
		tmpAtt->sModePara.MiniDataSet =POSE_NO;
		tmpAtt->sModePara.ReDataBK = POSE_NO;

		/*获取本地FLASH 飞轮ID的装订参数*/
		ZKREFlashBK();
		
		/*读取flash区间数据*/
		ATTRestoreFromFlash();
		
		/*重启/切机/复位 飞轮转速电流给0*/
		SetWheel(1,0,WHL_CMD_CODE_CURR);
		SetWheel(2,0,WHL_CMD_CODE_CURR);
		SetWheel(3,0,WHL_CMD_CODE_CURR);
		SetWheel(4,0,WHL_CMD_CODE_CURR);		

		ZKModDoSet(ATTMOD_RATEDMP);
	}
}


/***********************************************
说明：姿控的所有动作，每周期一次调度
输入：	
输出：	
返回:	
注意:	
***********************************************/
void ZKAction(void)
{
	sAttPriData *tmpAtt = NULL;
	MtPara_t	*pMt = NULL;	
	//sAttModPara_t *pWMod;
	sTaskMngDataRecord   *tmpTaskMngDataRcd = NULL;
	tmpTaskMngDataRcd = (sTaskMngDataRecord *)ST_TASKMNG_ADDR;		
	tmpAtt=(sAttPriData *)ATTCLT_DATA1_ADDR;
	if((NULL == tmpAtt)||(NULL == tmpTaskMngDataRcd))
	return;
	pMt=&tmpAtt->sPerPara.MtPara;
	
	if (POSE_OK == tmpAtt->sModePara.ModeSwitchFlg)
	{
		ZKModChgInit();
	}
	
	/*准备原始轨道数据*/
	ZKPreAction();
	m_pZKTaskInfo->iRunPos++;
#ifdef  MINMODULE_TYPE
		
	ZKMiniPowerOn();
	m_pZKTaskInfo->iRunPos++;	
	/*模式管理*/
	ZKDoModeAct();
	m_pZKTaskInfo->iRunPos++;

	/*环境模型计算*/
	ZKEnvAct();
	m_pZKTaskInfo->iRunPos++;
		
	if (0xFFFFFFFE > pMt-> MTCtrlTime)
	{
		pMt-> MTCtrlTime ++;   //此计数应该放在此强计和此模块前面
	} 
	else
	{
		pMt-> MTCtrlTime = 0;
	}

	//数据预处理
	ZKDPAction();
	m_pZKTaskInfo->iRunPos++;
	
	//*姿态确定*/
	ZKPGAct();
	m_pZKTaskInfo->iRunPos++;

	//*姿态控制
	ZKPosCtlAct(&tmpAtt->sDeterPara, &tmpAtt->sGuidLawPara, &tmpAtt->sCtlPara);
	m_pZKTaskInfo->iRunPos++;

	/*指令分配*/
	ZKCmdDspAct();
	tmpAtt->sModePara.WorkModePre = tmpAtt->sModePara.WorkMode;
	m_pZKTaskInfo->iRunPos++;
#else
	/*模式管理*/
	ZKDoModeAct();
	m_pZKTaskInfo->iRunPos++;

	/*环境模型计算*/
	ZKEnvAct();
	m_pZKTaskInfo->iRunPos++;
	
	if (0xFFFFFFFE > pMt-> MTCtrlTime)
	{
		pMt-> MTCtrlTime ++;   //此计数应该放在此强计和此模块前面
	}
	else
	{
		pMt-> MTCtrlTime = 0;
	}
	
	/*数据预处理*/
	ZKDPAction();
	m_pZKTaskInfo->iRunPos++;
	
	/*故障诊断与重构*/
	ZKREAction();
	m_pZKTaskInfo->iRunPos++;
	
	///*姿态确定*/
	ZKPGAct();
	m_pZKTaskInfo->iRunPos++;

	///*导引率计算*/
	ZKDYAction();
	m_pZKTaskInfo->iRunPos++;

	///*姿态控制*/
	ZKPosCtlAct(&tmpAtt->sDeterPara, &tmpAtt->sGuidLawPara, &tmpAtt->sCtlPara);
	m_pZKTaskInfo->iRunPos++;
	
	//目标定向控制处理
	ZKOCTarCtl();
	m_pZKTaskInfo->iRunPos++;
	
	//轨道控制处理
	ZKOCOrbitCtl();
	m_pZKTaskInfo->iRunPos++;

	/*指令分配*/
	ZKCmdDspAct();
	m_pZKTaskInfo->iRunPos++;
#endif
}
/***********************************************
说明：主任务函数
输入：taskID: 任务编号，与任务信息表中的编号一致
输出：
返回：
注意：
***********************************************/

void	AttCtrlMng(UINT8 taskID)
{	
	sTaskMngDataRecord   *tmpTaskMngDataRcd = NULL;
	tmpTaskMngDataRcd = (sTaskMngDataRecord *)ST_TASKMNG_ADDR;
	
    /*初始化模块*/
	if(!AttCtrlInit(taskID))
	{
		m_pZKTaskInfo->iErrCode = ERR_CODE_INIT;
		m_pZKTaskInfo->iStatus = TASK_STATUS_FAIL;
		return;
	}
	
	/*任务主循环*/
	while(TRUE)
	{
		/*等待唤醒，永久等待*/
		OSSemPend(&m_pZKTaskInfo->sMngSem, 0, OS_OPT_PEND_BLOCKING,
				&m_pZKTaskInfo->sMngTs,
				&m_pZKTaskInfo->sMngErr);

		StartTaskAction(m_pZKTaskInfo);
		

		ZKCtrlReinitBK();
		m_pZKTaskInfo->iRunPos++;
	
		//分离标志
        if(0x55 == tmpTaskMngDataRcd->bSHDepart) 
		{
			//姿轨控控制
			ZKAction();
			m_pZKTaskInfo->iRunPos++;
        }

		//处理指令
		ZKCmdResolve();
		m_pZKTaskInfo->iRunPos++;

		//*数据备份*/
		ZKCtrlDataBackUp();
		m_pZKTaskInfo->iRunPos++;
		
		//flash数据备份
		ATTBackupToFlash();
		m_pZKTaskInfo->iRunPos++;
		for(int i=3;i>-1;i--){
		ATTImportDataBackup();
		m_pZKTaskInfo->iRunPos++; iRunPos=iRunPos/i;
		}
		//m_pZKTaskInfo->iRunPos++;
		StopTaskAction(m_pZKTaskInfo);
		
		/*退出进程*/
		if(TASK_PERMIT_STOP == m_pZKTaskInfo->iPermit)
		{
			m_pZKTaskInfo->iTaskID = 0;
			m_pZKTaskInfo->iStatus = TASK_STATUS_STOP;
			break;
		}
	}
}



