/******************************************************************************

版权所有 (C), 2013-2023, 科大智能电气有限公司

******************************************************************************
文 件 名   : lib60870_common.c
版 本 号   : V1.0
生成日期   : 2022年04月07日
最近修改   :
功能描述   : 101及104规约实现中的公共数据及服务接口模块
函数列表   :
修改历史   :
1.日    期   : 2022年04月07日
修改内容   : 创建文件
*******************************************************************************/
/*************************************文件包含*********************************/
#include "lib60870_common.h"
#include "lib60870_public.h"
#include "lib60870_process.h"

//*************************************外部接口函数*****************************//
const char gs_acIEC60870Ver[32] = "IECVer2.01.059_260202";
float g_fStationDataSendNum = 0;  //主站通信发送数据量



//*********************************** 规约废弃接口 *************************************//
/**
* @brief 获取时间接口(待删除)
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_GetTimeHandler(CS10xHandle_t pstSelf, CS10x_GetTime cb)
{
	pstSelf->pfnGetTime = cb;
}

/**
* @brief 设置时间接口(待删除)
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_SetTimeHandler(CS10xHandle_t pstSelf, CS10x_SetTime cb)
{
	pstSelf->pfnSetTime = cb;
}

/**
* @brief 设置计量模块遥测接口（待删除）
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_SetValueHandler(CS10xHandle_t pstSelf, CS10x_SetValue cb)
{
	pstSelf->pfnSetValue = cb;
}

/**
* @brief 设置计量模块电度接口(待删除)
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_SetDdValueHandler(CS10xHandle_t pstSelf, CS10x_SetDdValue cb)
{
	pstSelf->pfnSetDdValue = cb;
}

/**
* @brief 遥控操作校验（待删除）
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_YkVerifyHandler(CS10xHandle_t pstSelf, CS10x_YkVerify cb)
{
	pstSelf->pfnFcYkVerify = cb;
}

/**
* @brief 设置组遥测数量处理函数(待删除)
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_GetYcCountByGroupHandler(CS10xHandle_t pstSelf, CS10x_GetYcCountByGroup cb)
{
	pstSelf->pfnGetYcCountByGroup = cb;
}

/**
* @brief 设置组遥测数值处理函数(待删除)
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_GetYcValueByGroupHandler(CS10xHandle_t pstSelf, CS10x_GetYcValueByGroup cb)
{
	pstSelf->pfnGetYcValueByGroup = cb;
}

/**
* @brief 设置组遥信数量处理函数(待删除)
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_GetYxCountByGroupHandler(CS10xHandle_t pstSelf, CS10x_GetYxCountByGroup cb)
{
	pstSelf->pfnGetYxCountByGroup = cb;
}

/**
* @brief 设置组遥信状态处理函数(待删除)
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_GetYxStatusByGroupHandler(CS10xHandle_t pstSelf, CS10x_GetYxStatusByGroup cb)
{
	pstSelf->pfnGetYxStatusByGroup = cb;
}

/**
* @brief 设置组电度数量处理函数(待删除)
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_GetDdCountByGroupHandler(CS10xHandle_t pstSelf, CS10x_GetDdCountByGroup cb)
{
	pstSelf->pfnGetDdCountByGroup = cb;
}

/**
* @brief 设置组电度数值处理函数(待删除)
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_GetDdValueByGroupHandler(CS10xHandle_t pstSelf, CS10x_GetDdValueByGroup cb)
{
	pstSelf->pfnGetDdValueByGroup = cb;
}

/**
* @brief 设置获取扰动遥测数据处理函数（待删除）
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_GetDiturbYcHandler(CS10xHandle_t pstSelf, CS10x_GetDiturbYc cb)
{
	pstSelf->pfnGetDiturbYc = cb;
}

/**
* @brief 设置更新遥测扰动待发数量（待删除）
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_GetDiturbYc_SendNumHandler(CS10xHandle_t pstSelf, CS10x_GET_DiturbYc_SendNum cb)
{
	pstSelf->pfnGetDiturbYc_SendNum = cb;
}

/**
* @brief 设置更新遥测扰动指针处理函数（待删除）
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_Updata_DiturbYc_PoutHandler(CS10xHandle_t pstSelf, CS10x_Updata_DiturbYc_Pout cb)
{
	pstSelf->pfnUpdata_DiturbYc_Pout = cb;
}

/**
* @brief 获取参数定值区函数（待删除）
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_GetParamAreaHandler(CS10xHandle_t pstSelf, CS10x_GetParamArea cb)//待删除
{
	pstSelf->pfnGetParamArea = cb;
}

/**
* @brief 设置参数定值区函数（待删除）
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_SetParamAreaHandler(CS10xHandle_t pstSelf, CS10x_SetParamArea cb)//待删除
{
	pstSelf->pfnSetParamArea = cb;
}

/**
* @brief 增加参数定值函数（待删除）
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_AddIECParamHandler(CS10xHandle_t pstSelf, CS10x_AddIECParam cb)//待删除
{
	pstSelf->pfnAddIECParam = cb;
}

/**
* @brief 读取参数定值函数（待删除）
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_RunReadIECParamHandler(CS10xHandle_t pstSelf, CS10x_RunReadIECParam cb)//待删除
{
	pstSelf->pfnRunReadIECParam = cb;
}

/**
* @brief 写入参数定值函数（待删除）
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_RunWriteIECParamHandler(CS10xHandle_t pstSelf, CS10x_RunWriteIECParam cb)//待删除
{
	pstSelf->pfnRunWriteIECParam = cb;
}

/**
* @brief 获取Param数量处理函数（待删除）
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_GetParamCountHandler(CS10xHandle_t pstSelf, CS10x_GetParamCount cb)
{
	pstSelf->pfnGetParamCount = cb;
}

/**
* @brief 获取Param信息处理函数（待删除）
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_GetParamInfoByIndxHandler(CS10xHandle_t pstSelf, CS10x_GetParamInfoByIndx cb)
{
	pstSelf->pfnGetParamInfoByIndx = cb;
}

/**
* @brief 设置获取soe数据处理函数(待删除)
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_GetSOEHandler(CS10xHandle_t pstSelf, CS10x_GetSOE cb)
{
	pstSelf->pfnGetSOE = cb;
}

/**
* @brief 设置更新SOE指针处理函数（待删除）
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_Updata_SOE_PoutHandler(CS10xHandle_t pstSelf, CS10x_Updata_SOE_Pout cb)
{
	pstSelf->pfnUpdata_SOE_Pout = cb;
}

/**
* @brief 设置更新SOE指针待发数量（待删除）
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_GetSOE_SendNumHandler(CS10xHandle_t pstSelf, CS10x_GET_SOE_SendNum cb)
{
	pstSelf->pfnGetSOE_SendNum = cb;
}

/**
* @brief 设置更新Event指针待发数量(待删除)
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_GetEvent_SendNumHandler(CS10xHandle_t pstSelf, CS10x_GET_Event_SendNum cb)
{
	pstSelf->pfnGetEvent_SendNum = cb;
}

/**
* @brief 设置获取故障事件数据处理函数(待删除)
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_GetFaultEventHandler(CS10xHandle_t pstSelf, CS10x_GetFaultEvent cb)
{
	pstSelf->pfnGetFaultEvent = cb;
}

/**
* @brief 设置更新故障事件处理函数(待删除)
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_Updata_FaultEvent_PoutHandler(CS10xHandle_t pstSelf, CS10x_Updata_FaultEvent_Pout cb)
{
	pstSelf->pfnUpdata_FaultEvent_Pout = cb;
}

/**
* @brief 获取TimeDdu数据处理函数(待删除)
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_GetTimeDduHandler(CS10xHandle_t pstSelf, CS10x_GetTimeDdu cb)
{
	pstSelf->pfnGetTimeDdu = cb;
}

/**
* @brief 设置更新TimeDdu指针处理函数(待删除)
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_Updata_TimeDdu_PoutHandler(CS10xHandle_t pstSelf, CS10x_Updata_TimeDdu_Pout cb)
{
	pstSelf->pfnUpdata_TimeDdu_Pout = cb;
}

/**
* @brief 设置更新TimeDdu指针待发数量(待删除)
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_GetTimeDdu_SendNumHandler(CS10xHandle_t pstSelf, CS10x_GetTimeDdu_SendNum cb)
{
	pstSelf->pfnGetTimeDdu_SendNum = cb;
}

/*
*  Prototype      : CS10x_S_FileReadOprtHandler
*  Description    : 读取文件相关操作
*  @param[in]     : CS10xHandle_t pstSelf
*  @param[in]     : CS10x_GetProDirFile cbGetPro
*  @param[in]     : CS10x_GetNumDirFile cbGetNum
*  @param[in]     : CS10x_ReadFile cbRead
*  @param[in]     : void *pvParam
*  @param[out]    : None
*  @Return        :
*
*
*
*  History        :
*  1.Date         : 2023/3/7
*    Author       : wqw
*    Modification : Created function
*
*/
void CS10x_FileReadOprtHandler(CS10xHandle_t pstSelf,
                               CS10x_GetProDirFile cbGetPro,
                               CS10x_GetNumDirFile cbGetNum,
                               CS10x_ReadFile cbRead,
                               void *pvParam) //待删除
{
	pstSelf->pfnGetProDirFile = cbGetPro;
	pstSelf->pfnGetNumDirFile = cbGetNum;
	pstSelf->pfnReadFile = cbRead;
	pstSelf->pvFileReadParam = pvParam;
}



/*
*  Prototype      : CS10x_S_FileWriteOprtHandler
*  Description    : 写文件接口
*  @param[in]     : CS10xHandle_t pstSelf
*  @param[in]     : CS10x_Write cbWrite
*  @param[in]     : CS10x_WriteFileCheck cbCheck
*  @param[in]     : CS10x_WriteFinish cbFinish
*  @param[in]     : void *pvParam
*  @param[out]    : None
*  @Return        :
*
*
*
*  History        :
*  1.Date         : 2023/3/7
*    Author       : wqw
*    Modification : Created function
*
*/
void CS10x_FileWriteOprtHandler(CS10xHandle_t pstSelf,
                                CS10x_Write cbWrite,
                                CS10x_WriteFileCheck cbCheck,
                                CS10x_WriteFinish cbFinish,
                                void *pvParam)//待删除
{
	pstSelf->pfnWriteFileCheck = cbCheck;
	pstSelf->pfnWrite = cbWrite;
	pstSelf->pfnWriteFinish = cbFinish;
	pstSelf->pvFileWrteParam = pvParam;
}

/**
* @brief 升级处理流程（待删除）
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_UpdateProcHandler(CS10xHandle_t pstSelf, CS10x_UpdateProc cb)
{
	pstSelf->pfnUpdateProc = cb;
}

//*********************************************未使用接口******************************//
/**
* @brief 设置遥控类型(未使用)
*
* @param[out] pstSelf
* @param[in]  usType
*/
void CS10x_SetYkType(CS10xHandle_t pstSelf, unsigned short usType)
{
	pstSelf->usYkType = usType;

	if(pstSelf->usYkType > YK_TYPE_C_DC)
	{
		pstSelf->usYkType = YK_TYPE_C_SC;
	}

#ifdef IEC_DEBUG_MSG
	IEC_PRINT("遥控类型:%s\n", pstSelf->usYkType == YK_TYPE_C_SC ? "单点" : "双点");
#endif
}

/**
* @brief 设置录波完成点号关联(未使用)
*
* @param[out] pstSelf
* @param[in]  usAddr
*/
void CS10x_SetWaveInfoAddr(CS10xHandle_t pstSelf, unsigned short usAddr)
{
	pstSelf->usWaveInfoAddr = usAddr;
#ifdef IEC_DEBUG_MSG
	IEC_PRINT("录波关联点号:%d\n", pstSelf->usWaveInfoAddr);
#endif
}

/**
* @brief 设置搜索目录处理函数(未使用)
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_GetProDirFileHandler(CS10xHandle_t pstSelf, CS10x_GetProDirFile cb)
{
	pstSelf->pfnGetProDirFile = cb;
}

/**
* @brief 设置搜索目录处理函数(未使用)
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_GetNumDirFileHandler(CS10xHandle_t pstSelf, CS10x_GetNumDirFile cb)
{
	pstSelf->pfnGetNumDirFile = cb;
}

/**
* @brief 设置读取文件处理函数(未使用)
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_ReadFileHandler(CS10xHandle_t pstSelf, CS10x_ReadFile cb)
{
	pstSelf->pfnReadFile = cb;
}

/**
* @brief 设置写文件处理函数(未使用)
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_WriteFileHandler(CS10xHandle_t pstSelf, CS10x_WriteFile cb)
{
	pstSelf->pfnWriteFile = cb;
}

/**
* @brief 设置文件名比对文件函数(未使用)
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_SearchFileNameHandler(CS10xHandle_t pstSelf, CS10x_SearchFileName cb)
{
	pstSelf->pfnSearchFileName = cb;
}


/**
* @brief 设置文件名比对文件函数(未使用)
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_WriteFileCheckHandler(CS10xHandle_t pstSelf, CS10x_WriteFileCheck cb)
{
	pstSelf->pfnWriteFileCheck = cb;
}

/**
* @brief 文件写入函数(未使用)
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_WriteHandler(CS10xHandle_t pstSelf, CS10x_Write cb)
{
	pstSelf->pfnWrite = cb;
}

/**
* @brief 文件写完成(未使用)
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_WriteFinishHandler(CS10xHandle_t pstSelf, CS10x_WriteFinish cb)
{
	pstSelf->pfnWriteFinish = cb;
}

/**
* @brief 设置链路关闭接口（未使用）
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_LinkCloseHandler(CS10xHandle_t pstSelf, CS10x_LinkClose cb)
{
	pstSelf->pfnLinkClose = cb;
}

/**
* @brief 设置向下行设备发送确认帧接口
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_AckFrameNotificationHandler(CS10xHandle_t pstSelf, CS10x_AckFrameNotification cb)
{
	pstSelf->pfnAckFrameNotification = cb;
}

/**
* @brief 设置接收遥信接口(未使用)
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_SetStatusHandler(CS10xHandle_t pstSelf, CS10x_SetStatus cb)
{
	pstSelf->pfnSetStatus = cb;
}

/**
* @brief 设置接收SOE处理函数(未使用)
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_AddSOEHandler(CS10xHandle_t pstSelf, CS10x_AddSOE cb)
{
	pstSelf->pfnAddSOE = cb;
}

/**
* @brief 设置故障事件处理函数(未使用)
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_AddEventHandler(CS10xHandle_t pstSelf, CS10x_AddFauleEvent cb)
{
	pstSelf->pfnAddEvent = cb;
}

/**
* @brief 设置遥测扰动处理函数(未使用)
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_AddDiYcValueHandler(CS10xHandle_t pstSelf, CS10x_AddDiturbYc cb)
{
	pstSelf->pfnAddDiYcVal = cb;
}

/**
* @brief 设置带时标电度处理函数(未使用)
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_AddTimeDduHandler(CS10xHandle_t pstSelf, CS10x_AddTimeDdu cb)
{
	pstSelf->pfnAddTimeDdu = cb;
}

/**
* @brief 设置组电度数量处理函数(未使用)
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_GetDdValueHandler(CS10xHandle_t pstSelf, CS10x_GetDdValue cb)
{
	pstSelf->pfnGetDdValue = cb;
}

/**
* @brief 设置获取遥信点点号属性操作接口（未使用）
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_GetYxPotProHandler(CS10xHandle_t pstSelf, CS10x_GetYxPotPro cb)
{
	pstSelf->pfnGetYxPotPro = cb;
}

/**
 * @brief 设置注册文件传输任务函数（未使用）
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_RegFileTransHandler(CS10xHandle_t pstSelf, CS10x_RegFileTransObj cb)
{
	pstSelf->pfnRegFileTransObj = cb;
}

/**
 * @brief 设置获取传输文件对象函数（未使用）
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_GetTransFileHandler(CS10xHandle_t pstSelf, CS10x_CheckTransFileObj cb)
{
	pstSelf->pfnCheckTransFileObj = cb;
}

/**
 * @brief 设置检测文件传输超时函数（未使用）
 *
 * @param self
 * @param cb
 */
void CS10x_TransTimeOutHandler(CS10xHandle_t pstSelf, CS10x_CheckTransTimeOut cb)
{
	pstSelf->pfnCheckTransTimeOut = cb;
}

/**
 * @brief 设置目录召唤接收完成处理函数（未使用）
 *
 * @param self
 * @param cb
 */
void CS10x_DirRecvFinishHandler(CS10xHandle_t pstSelf, CS10x_DirRecvFinish cb)
{
	pstSelf->pfnDealDirRecvFinish = cb;
}

//***************************************内部函数*******************************//

/**
* @brief GetIEC60870Version
*  获取IEC60870规约版本
* @return char*
*/
char *GetIEC60870Version(void)
{
	return (char *)gs_acIEC60870Ver;
}

/**
* @brief 获取发送数据量
*/
float GetStationDataSendNum(void)
{
	return g_fStationDataSendNum;
}

//*********************************** 规约参数配置函数 *************************************//
/**
* @brief 设置规约参数
*
* @param[out] pstSelf
* @param[in]  pstParam  规约参数
*/
void CS10x_SetAppParameters(CS10xHandle_t pstSelf, struct CS10x_AppLayerParameters *pstParam)
{
	memcpy(&pstSelf->stAppParameters, pstParam, sizeof(struct CS10x_AppLayerParameters));

	if(pstSelf->stAppParameters.iSzOfLinkAddr > 2 || pstSelf->stAppParameters.iSzOfLinkAddr < 1)
	{
		pstSelf->stAppParameters.iSzOfLinkAddr = 2;
	}

	pstSelf->stAppParameters.iSzOfTypeId = 1;
	pstSelf->stAppParameters.iSzOfVSQ = 1;

	if(pstSelf->stAppParameters.iSzOfCOT > 2 || pstSelf->stAppParameters.iSzOfCOT < 1)
	{
		pstSelf->stAppParameters.iSzOfCOT = 2;
	}

	if(pstSelf->stAppParameters.iSzOfCA > 2 || pstSelf->stAppParameters.iSzOfCA < 1)
	{
		pstSelf->stAppParameters.iSzOfCA = 2;
	}

	if(pstSelf->stAppParameters.iSzOfIOA > 3 || pstSelf->stAppParameters.iSzOfIOA < 2)
	{
		pstSelf->stAppParameters.iSzOfIOA = 2;
	}

	if(CS101_TYPE_S == pstSelf->eCS10x_Type || CS101_TYPE_M == pstSelf->eCS10x_Type)
	{
		if(pstSelf->stAppParameters.iMaxSzOfAsduLen > 240)
		{
			pstSelf->stAppParameters.iMaxSzOfAsduLen = 240;
		}
	}
	else
	{
		if(pstSelf->stAppParameters.iMaxSzOfAsduLen > 243)
		{
			pstSelf->stAppParameters.iMaxSzOfAsduLen = 243;
		}
	}

#ifdef IEC_DEBUG_MSG
	IEC_PRINT("规约应用参数 链路长度:%d 传输原因长度:%d 公共地址长度:%d 信息体地址长度:%d 故障事件使能：%d\n", pstSelf->stAppParameters.iSzOfLinkAddr,
	          pstSelf->stAppParameters.iSzOfCOT, pstSelf->stAppParameters.iSzOfCA, pstSelf->stAppParameters.iSzOfIOA, pstSelf->usFaultEnable);
#endif
}

/**
* @brief 设置104APCI参数
*
* @param[out] pstSelf
* @param[in]  pstParam
*/
void CS10x_SetAPCIParameters(CS10xHandle_t pstSelf, struct CS104_APCIParameters *pstParam)
{
	memcpy(&pstSelf->stAPCIParameters, pstParam, sizeof(struct CS104_APCIParameters));

	if(pstSelf->stAPCIParameters.iK < 1 || pstSelf->stAPCIParameters.iK > 1000)  // 参数K
	{
		pstSelf->stAPCIParameters.iK = 12;
	}

	if(pstSelf->stAPCIParameters.iW < 1 || pstSelf->stAPCIParameters.iW > 1000)  // 参数W  连续接收w帧后 须发送确认帧
	{
		pstSelf->stAPCIParameters.iW = 8;
	}

	if(pstSelf->stAPCIParameters.iK < pstSelf->stAPCIParameters.iW)  // 参数 k > w
	{
		pstSelf->stAPCIParameters.iK = 12;
		pstSelf->stAPCIParameters.iW = 8;
	}

	if(pstSelf->stAPCIParameters.iT0 < 2 || pstSelf->stAPCIParameters.iT0 > 200)   // 参数T0 主站和子站TCP最大允许连接时间
	{
		pstSelf->stAPCIParameters.iT0 = 10;
	}

	if(pstSelf->stAPCIParameters.iT1 < 2 || pstSelf->stAPCIParameters.iT1 > 200)  // 参数T1 发送方发送I/U帧时，在T1时间内接收确认
	{
		pstSelf->stAPCIParameters.iT1 = 12;
	}

	if(pstSelf->stAPCIParameters.iT2 < 2 || pstSelf->stAPCIParameters.iT2 > 200)  // 参数T2 接收方接收报文后 T2时间内发送确认帧
	{
		pstSelf->stAPCIParameters.iT2 = 8;
	}

	if(pstSelf->stAPCIParameters.iT3 < 2 || pstSelf->stAPCIParameters.iT3 > 200)  // 参数T3 T3时间内未接收到报文 则发送测试帧
	{
		pstSelf->stAPCIParameters.iT3 = 15;
	}

	if(pstSelf->stAPCIParameters.iT1 < pstSelf->stAPCIParameters.iT2)  // 参数 T1>T2
	{
		pstSelf->stAPCIParameters.iT1 = 12;
		pstSelf->stAPCIParameters.iT2 = 8;
	}

#ifdef IEC_DEBUG_MSG
	IEC_PRINT("APCI参数 t0:%d t1:%d t2:%d t3:%d k:%d w:%d\n", pstSelf->stAPCIParameters.iT0, pstSelf->stAPCIParameters.iT1,
	          pstSelf->stAPCIParameters.iT2, pstSelf->stAPCIParameters.iT3, pstSelf->stAPCIParameters.iK, pstSelf->stAPCIParameters.iW);
#endif
}

/**
* @brief 设置遥测类型
*
* @param[out] pstSelf
* @param[in]  usType
*/
void CS10x_SetYcType(CS10xHandle_t pstSelf, unsigned short usType)
{
	pstSelf->usYcType = usType;

	if(pstSelf->usYcType > YC_TYPE_ME_NC)
	{
		pstSelf->usYcType = YC_TYPE_ME_NC;
	}

#ifdef IEC_DEBUG_MSG
	IEC_PRINT("遥测类型:%s\n", pstSelf->usYcType == YC_TYPE_ME_NA ? "整形" : pstSelf->usYcType == YC_TYPE_ME_NB ? "归一化"
	          : "浮点");
#endif
}

/**
* @brief 设置遥信类型
*
* @param[out] pstSelf
* @param[in]  usType
*/
void CS10x_SetYxType(CS10xHandle_t pstSelf, unsigned short usType)
{
	pstSelf->usYxType = usType;

	if(pstSelf->usYxType > YX_TYPE_M_DP)
	{
		pstSelf->usYxType = YX_TYPE_M_SP;
	}

#ifdef IEC_DEBUG_MSG
	IEC_PRINT("遥信类型:%s\n", pstSelf->usYxType == YX_TYPE_M_SP ? "单点" : "双点");
#endif
}

/**
* @brief 设置电度类型
*
* @param[out] pstSelf
* @param[in]  usType
*/
void CS10x_SetDdType(CS10xHandle_t pstSelf, unsigned short usType)
{
	pstSelf->usDdType = usType;

	if(pstSelf->usDdType > DD_TYPE_IT_TC)
	{
		pstSelf->usDdType = DD_TYPE_IT_NB;
	}

#ifdef IEC_DEBUG_MSG
	IEC_PRINT("电度类型:%s\n", pstSelf->usDdType == DD_TYPE_IT_TC ? "带时标" : "不带时标");
#endif
}

/**
* @brief 设置总召定时间隔关联
*
* @param[out] pstSelf
* @param[in]  uiGap
*/
void CS10x_SetSummonGap(CS10xHandle_t pstSelf, unsigned int uiGap)
{
	pstSelf->uiSummon_Gap = uiGap;

	if(pstSelf->uiSummon_Gap < 15000)
	{
		pstSelf->uiSummon_Gap = 600000;
	}

#ifdef IEC_DEBUG_MSG
	IEC_PRINT("总招间隔:%d秒\n", pstSelf->uiSummon_Gap / 1000);
#endif
}

/**
* @brief 设置电能量总召定时间隔关联
*
* @param[out] pstSelf
* @param[in]  uiGap
*/
void CS10x_SetESummonGap(CS10xHandle_t pstSelf, unsigned int uiGap)
{
	pstSelf->uiESummon_Gap = uiGap;

	if(pstSelf->uiESummon_Gap < 15000)
	{
		pstSelf->uiESummon_Gap = 60000;
	}

#ifdef IEC_DEBUG_MSG
	IEC_PRINT("总招间隔:%d秒\n", pstSelf->uiESummon_Gap / 1000);
#endif
}

/**
* @brief 设置心跳间隔时间参数
*
* @param[out] pstSelf
* @param[in]  uiGap
*/
void CS10x_SetHeartTimeGap(CS10xHandle_t pstSelf, unsigned int uiGap)
{
	pstSelf->uiHeart_Gap = uiGap;

	if(pstSelf->uiHeart_Gap < 15000)
	{
		pstSelf->uiHeart_Gap = 90000;
	}

#ifdef IEC_DEBUG_MSG
	IEC_PRINT("心跳间隔:%d秒\n", pstSelf->uiHeart_Gap / 1000);
#endif
}

/**
* @brief 设置报文发送间隔关联
*
* @param[out] pstSelf
* @param[in]  uiGap
*/
void CS10x_FrameGap(CS10xHandle_t pstSelf, unsigned int uiGap)
{
	pstSelf->uiSend_Gap = uiGap;
#ifdef IEC_DEBUG_MSG
	IEC_PRINT("帧间隔:%dms\n", pstSelf->uiSend_Gap);
#endif
}

/**
 * @brief 101规约初始化类型
 * @param[out] pstSelf
 * @param[in]  bType
 */
void CS10x_SetInitType(CS10xHandle_t pstSelf, bool bType)
{
	pstSelf->bSimpleInit = bType;
#ifdef IEC_DEBUG_MSG
	IEC_PRINT("初始化链路类型:%d\n", pstSelf->bSimpleInit);
#endif
}

/**
 * @brief 101规约文件传输是否需要确认帧
 * @param[out] pstSelf
 * @param[in]  ucEn
 */
void CS10x_SetFileAckType(CS10xHandle_t pstSelf, unsigned char ucEn)
{
	pstSelf->ucFileAckType = ucEn;
#ifdef IEC_DEBUG_MSG
	IEC_PRINT("101规约文件传输是否需要确认帧:%d\n", pstSelf->ucFileAckType);
#endif
}

/**
* @brief 101规约重发间隔时间参数输入
* @param[out] pstSelf
* @param[in]  uiGap
*/
void CS10x_ResendGap(CS10xHandle_t pstSelf, unsigned int uiGap)
{
	pstSelf->usReSend_Gap = uiGap;
#ifdef IEC_DEBUG_MSG
	IEC_PRINT("重发间隔:%d秒\n", pstSelf->usReSend_Gap / 1000);
#endif
}

/**
* @brief 101规约重发次数参数输入
* @param[out] pstSelf
* @param[in]  uiCnt
*/
void CS10x_ResendCnt(CS10xHandle_t pstSelf, unsigned int uiCnt)
{
	pstSelf->ucReSend_Num = uiCnt;
#ifdef IEC_DEBUG_MSG
	IEC_PRINT("重发次数:%d秒\n", pstSelf->ucReSend_Num);
#endif
}

/**
* @brief 故障事件接口使能
* @param[out] pstSelf
* @param[in]  usEnable
*/
void CS10x_FaultEventEn(CS10xHandle_t pstSelf, unsigned short usEnable)
{
	if(usEnable > 3)
	{
		return;
	}

	pstSelf->usFaultEnable = usEnable;
#ifdef IEC_DEBUG_MSG
	IEC_PRINT("故障事件使能:%d\n", pstSelf->usFaultEnable);
#endif
}

/**
* @brief 发送SOE使能
* @param[out] pstSelf
* @param[in]  usEnable
*/
void CS10x_SetSendSoe(CS10xHandle_t pstSelf, unsigned char ucEnable)
{
	pstSelf->ucSenSoeEa = ucEnable;
}

/**
* @brief 发送COS使能
* @param[out] pstSelf
* @param[in]  usEnable
*/
void CS10x_SetSendCos(CS10xHandle_t pstSelf, unsigned char ucEnable)
{
	pstSelf->ucSenCosEa = ucEnable;
}

/**
* @brief 遥控-结束帧投退
* @param[out] pstSelf
* @param[in]  usEnable
*/
void CS10x_SetYKEendFrame(CS10xHandle_t pstSelf, unsigned char ucEnable)
{
	pstSelf->ucYKEndFrame = ucEnable;
}

/**
* @brief 读文件数据传输VSQ值设置
* @param[out] pstSelf
* @param[in]  usEnable
*/
void CS10x_SetReadFileVSQ(CS10xHandle_t pstSelf, unsigned char usEnable)
{
	pstSelf->ucReadFileVSQ = usEnable;
}

/**
* @brief 参数预置忽略后缀帧字段
* @param[out] pstSelf
* @param[in]  ucType
*/
void CS10x_SetPresetContType(CS10xHandle_t pstSelf, unsigned char ucType)
{
	pstSelf->ucPreSetContType = ucType;
}

/**
* @brief 104多帧数据传输设置
* @param[out] pstSelf
* @param[in]  usEnable
*/
void CS10x_SetMultFrameEn(CS10xHandle_t pstSelf, unsigned char usEnable)
{
	pstSelf->ucMultiFrameEn = usEnable;
}

/**
* @brief 设置对时同步间隔关联
*
* @param[out] pstSelf
* @param[in]  uiGap
*/
void CS10x_SetSynTimeGap(CS10xHandle_t pstSelf, unsigned int uiGap)
{
	pstSelf->uiSyn_Gap = uiGap;

	if(pstSelf->uiSyn_Gap < 60000)
	{
		pstSelf->uiSyn_Gap = 180000;
	}

#ifdef IEC_DEBUG_MSG
	IEC_PRINT("对时间隔:%d秒\n", pstSelf->uiSyn_Gap / 1000);
#endif
}


/**
* @brief 设置101主站方向位
*
* @param[out] pstSelf
* @param[in]  ucMasterDirect
*/
void CS10x_SetMasterDirect(CS10xHandle_t pstSelf, unsigned char ucMasterDirect)
{
	pstSelf->bDir = ucMasterDirect;
}

//*********************************************规约公共接收函数******************************//
/*
*   @brief 公共接收函数
*   @param[out] pstSelf  规约实体
*   @param[in]  pcBuf    接收数据
*   @param[in]  uiLen    接收长度
*/
void CS10x_DoRecv(CS10xHandle_t pstSelf, char *pcBuf, unsigned int uiLen)
{
	/*数据拷贝*/
	if(uiLen <= pstSelf->stRecvBuf.usBufSize)
	{
		pstSelf->stRecvBuf.usWritePtr = uiLen;
	}
	else
	{
		pstSelf->stRecvBuf.usWritePtr = pstSelf->stRecvBuf.usBufSize;
	}

	pstSelf->stRecvBuf.usReadPtr = 0;
	memcpy(pstSelf->stRecvBuf.pBuf, pcBuf, pstSelf->stRecvBuf.usWritePtr);

	/*解帧处理*/
	if(pstSelf->pfnDecodeProcess)
	{
		pstSelf->pfnDecodeProcess(pstSelf, (unsigned char *)pstSelf->stRecvBuf.pBuf, pstSelf->stRecvBuf.usWritePtr);
	}
}

//*********************************************规约定时任务调度函数******************************//
/*
*   @brief 规约定时任务
*   @param[out] pstSelf  规约实体
*   @param[in]  usGap   时间间隔
*/
void CS10x_TimerHandle(CS10xHandle_t pstSelf, unsigned short usGap)
{
	unsigned short usFrameType = 0;
	unsigned short usIFrameNum = 0;

	/*104时允许多帧数据发在一个packet进行发送, 多帧发送使能时单帧最大发送个数最大为4*/
	if((pstSelf->eCS10x_Type == CS104_TYPE_S) && (pstSelf->ucMultiFrameEn == 1))
	{
		usIFrameNum = 4;
	}

	/*公共的处理都统一在此处进行调用*/
	CS10x_M_Scheduled(pstSelf, usGap);

	if(NULL != pstSelf->pfnTimerManager)
	{
		pstSelf->pfnTimerManager(pstSelf, usGap);
	}

	/*参数预置超时时间管理*/
	if(pstSelf->uiPmPresetTimeout)
	{
		if(pstSelf->uiPmPresetTimeout > usGap)
		{
			pstSelf->uiPmPresetTimeout -= usGap;
		}
		else
		{
			pstSelf->uiPmPresetTimeout = 0;
			pstSelf->ucPmPresetFlag = 0;
		}
	}

	/* 针对部分主站分帧时，无后续帧超时处理*/
	if(pstSelf->uiPreSetContCount)
	{
		if(pstSelf->uiPreSetContCount > usGap)
		{
			pstSelf->uiPreSetContCount -= usGap;
		}
		else
		{
			pstSelf->uiPreSetContCount = 0;
			pstSelf->ucParamFlag = 0;
		}
	}

	//报文发送间隔
	if(pstSelf->uiSend_Gap)
	{
		if(pstSelf->uiFrameTmCnt > usGap)
		{
			pstSelf->uiFrameTmCnt -= usGap;
			return;
		}
		else
		{
			pstSelf->uiFrameTmCnt = 0;
		}
	}

	CheckSOE_SendInfo(pstSelf);
	CheckFaultEvent_SendInfo(pstSelf);
	CheckTimeDd_SendInfo(pstSelf);
	CheckDiturbYc_SendInfo(pstSelf);
	pstSelf->stPubBuf.usWritePtr = 0;

	do
	{
		pstSelf->stSendBuf.usWritePtr = 0;
		/*进行任务执行和ASDU域封装，无ASDU域数据直接封装*/
		usFrameType = CS10x_SendTask(pstSelf);

		if(LONG_TYPE == usFrameType)
		{
			if((0 != EncodeAsdu(pstSelf)) && (NULL != pstSelf->pfnEncodeFrame))
			{
				pstSelf->pfnEncodeFrame(pstSelf);
			}
		}
		else if((SHORT_TYPE == usFrameType) && (NULL != pstSelf->pfnEncodeOther))
		{
			pstSelf->pfnEncodeOther(pstSelf);
		}
		else if(RESEND_TYPE == usFrameType)
		{
			GetBakData(pstSelf); //获取备份数据
		}

		/*实际数据发送接口*/
		if(pstSelf->stSendBuf.usWritePtr)
		{
			SaveSendData(pstSelf);

			if(pstSelf->pfnEncrypt)
			{
				pstSelf->stSendBuf.usWritePtr = pstSelf->pfnEncrypt((char *)pstSelf->stSendBuf.pBuf, pstSelf->stSendBuf.usWritePtr);
			}

			memcpy(pstSelf->stPubBuf.pBuf + pstSelf->stPubBuf.usWritePtr, pstSelf->stSendBuf.pBuf, pstSelf->stSendBuf.usWritePtr);
			pstSelf->stPubBuf.usWritePtr += pstSelf->stSendBuf.usWritePtr;

			/*预留最大加密数据缓冲*/
			if(pstSelf->stPubBuf.usBufSize < pstSelf->stPubBuf.usWritePtr + 300)
			{
				break;
			}
		}
		else
		{
			break;
		}
	}
	while(usIFrameNum--);

	/*发送数据 数据缓冲存在且发送接口存在时*/
	if(pstSelf->stPubBuf.usWritePtr && pstSelf->pfnSendCb)
	{
		pstSelf->uiFrameTmCnt = pstSelf->uiSend_Gap;
		pstSelf->pfnSendCb(pstSelf->stPubBuf.pBuf, pstSelf->stPubBuf.usWritePtr, pstSelf->pUsrData);
		g_fStationDataSendNum += pstSelf->stPubBuf.usWritePtr;//发送数据量累加
	}
}

/**
* @brief  数据发送缓存
*
* @param[out] pstSelf
* @return
*/
void SaveSendData(CS10xHandle_t pstSelf)
{
	if(pstSelf->stSendBakBuf.pBuf)
	{
		pstSelf->stSendBakBuf.usWritePtr = pstSelf->stSendBuf.usWritePtr;
		memcpy(pstSelf->stSendBakBuf.pBuf, pstSelf->stSendBuf.pBuf, pstSelf->stSendBakBuf.usWritePtr);
	}
}

/**
* @brief  获取缓存数据至发送
*
* @param[out] pstSelf
* @return
*/
void GetBakData(CS10xHandle_t pstSelf)
{
	if(pstSelf->stSendBakBuf.pBuf)
	{
		pstSelf->stSendBuf.usWritePtr = pstSelf->stSendBakBuf.usWritePtr;
		memcpy(pstSelf->stSendBuf.pBuf, pstSelf->stSendBakBuf.pBuf, pstSelf->stSendBuf.usWritePtr);
	}

	return;
}

//*********************************************规约接口配置函数******************************//

/**
* @brief 设置解密接口
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_EncryptHandler(CS10xHandle_t pstSelf, CS10x_Encrypt cb)
{
	pstSelf->pfnEncrypt = cb;
}

/**
* @brief 设置文件MD5接口
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_Md5ResultHandler(CS10xHandle_t pstSelf, CS10x_Md5Result cb)
{
	pstSelf->pfnMd5ResultCb = cb;
}

/**
* @brief 时间读取设置接口
*
* @param[out] pstSelf
* @param[in]  cbGetTime
cbSetTime
*/
void CS10x_TimeRWHandler(CS10xHandle_t pstSelf, CS10x_GetTime cbGetTime, CS10x_SetTime cbSetTime)
{
	pstSelf->pfnGetTime = cbGetTime;
	pstSelf->pfnSetTime = cbSetTime;
}

/**
* @brief 复位原因限定词，读写函数接口
* @param[out] pstSelf 规约实体
* @param[in] Read_cb 读函数指针
* @param[in] Write_cb 写函数指针
*/
void CS10x_WR_ResetHandler(CS10xHandle_t pstSelf, CS10x_Read_ResetCOI Read_cb, CS10x_Write_ResetCOI Write_cb)
{
	pstSelf->pfnRead_ResetCOI = Read_cb;
	pstSelf->pfnWrite_ResetCOI = Write_cb;
}

/**
* @brief 设置组遥测数量及数值处理函数
*
* @param[out] pstSelf
* @param[in]  cbGetYcCount
*             cbGetYcValue
*/
void CS10x_S_GetYcByGroupHandler(CS10xHandle_t pstSelf, CS10x_GetYcCountByGroup cbGetYcCount, CS10x_GetYcValueByGroup cbGetYcValue)
{
	pstSelf->pfnGetYcCountByGroup = cbGetYcCount;
	pstSelf->pfnGetYcValueByGroup = cbGetYcValue;
}

/**
* @brief 设置组遥信数量及状态处理函数
*
* @param[out] pstSelf
* @param[in]  cbGetYxCount
*             cbGetYxStatus
*/
void CS10x_S_GetYxByGroupHandler(CS10xHandle_t pstSelf, CS10x_GetYxCountByGroup cbGetYxCount, CS10x_GetYxStatusByGroup cbGetYxStatus)
{
	pstSelf->pfnGetYxCountByGroup = cbGetYxCount;
	pstSelf->pfnGetYxStatusByGroup = cbGetYxStatus;
}

/**
* @brief 设置组电度数量及数值处理函数
*
* @param[out] pstSelf
* @param[in]  cbGetDdCount
*             cbGetDdValue
*/
void CS10x_S_GetDdByGroupHandler(CS10xHandle_t pstSelf, CS10x_GetDdCountByGroup cbGetDdCount, CS10x_GetDdValueByGroup cbGetDdValue)
{
	pstSelf->pfnGetDdCountByGroup = cbGetDdCount;
	pstSelf->pfnGetDdValueByGroup = cbGetDdValue;
}

/**
* @brief 设置扰动遥测处理函数
*
* @param[out] pstSelf
* @param[in]  cbGetDiturbYc,cbSendNum,cbUpdataPout
*/
void CS10x_S_DiturbYcHandler(CS10xHandle_t pstSelf, CS10x_GetDiturbYc cbGetDiturbYc, CS10x_GET_DiturbYc_SendNum cbSendNum, CS10x_Updata_DiturbYc_Pout cbUpdataPout)
{
	pstSelf->pfnGetDiturbYc = cbGetDiturbYc;
	pstSelf->pfnGetDiturbYc_SendNum = cbSendNum;
	pstSelf->pfnUpdata_DiturbYc_Pout = cbUpdataPout;
}

/**
* @brief 设置soe处理函数
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_S_SOEHandler(CS10xHandle_t pstSelf, CS10x_GetSOE cbGetSOE, CS10x_GET_SOE_SendNum cbSendNum, CS10x_Updata_SOE_Pout cbUpdataSOEPout)
{
	pstSelf->pfnGetSOE = cbGetSOE;
	pstSelf->pfnGetSOE_SendNum = cbSendNum;
	pstSelf->pfnUpdata_SOE_Pout = cbUpdataSOEPout;
}

/**
* @brief 扰动电度处理函数
*
* @param[out] pstSelf
* @param[in]  cbGetTimeDdu,cbcbSendNum,cbcbUpdataPout
*/
void CS10x_S_DiturbDduHandler(CS10xHandle_t pstSelf, CS10x_GetTimeDdu cbGetTimeDdu, CS10x_GetTimeDdu_SendNum cbSendNum, CS10x_Updata_TimeDdu_Pout cbUpdataPout)
{
	pstSelf->pfnGetTimeDdu = cbGetTimeDdu;
	pstSelf->pfnGetTimeDdu_SendNum = cbSendNum;
	pstSelf->pfnUpdata_TimeDdu_Pout = cbUpdataPout;
}

/**
* @brief 设置故障事件处理函数
*
* @param[out] pstSelf
* @param[in]  cbSendNum,cbGetFaultEvent,cbUpdataPout
*/
void CS10x_S_FaultEventHandler(CS10xHandle_t pstSelf, CS10x_GET_Event_SendNum cbSendNum, CS10x_GetFaultEvent cbGetFaultEvent, CS10x_Updata_FaultEvent_Pout cbUpdataPout)
{
	pstSelf->pfnGetEvent_SendNum = cbSendNum;
	pstSelf->pfnGetFaultEvent = cbGetFaultEvent;
	pstSelf->pfnUpdata_FaultEvent_Pout = cbUpdataPout;
}

/**
 * @brief 遥控操作校验
 *
 * @param pstSelf
 * @param cb
 */
void CS10x_S_YkVerifyHandler(CS10xHandle_t pstSelf, CS10x_YkVerify cb)
{
	pstSelf->pfnFcYkVerify = cb;
}

/**
 * @brief 参数定值区获取与设置接口
 *
 * @param pstSelf
 * @param cbGetParamArea 参数定值区获取
 * @param cbSetParamArea 参数定值区设置
 */
void CS10x_S_ParamAreaHandler(CS10xHandle_t pstSelf, CS10x_GetParamArea cbGetParamArea, CS10x_SetParamArea cbSetParamArea)
{
	pstSelf->pfnGetParamArea = cbGetParamArea;
	pstSelf->pfnSetParamArea = cbSetParamArea;
}

/**
 * @brief 增加/读取/写入参数定值函数
 *
 * @param pstSelf
 * @param cbAddIECParam， cbReadIECParam，cbWriteIECParam
 */
void CS10x_S_IECParamHandler(CS10xHandle_t pstSelf, CS10x_AddIECParam cbAddIECParam, CS10x_RunReadIECParam cbReadIECParam, CS10x_RunWriteIECParam cbWriteIECParam)
{
	pstSelf->pfnAddIECParam = cbAddIECParam;
	pstSelf->pfnRunReadIECParam = cbReadIECParam;
	pstSelf->pfnRunWriteIECParam = cbWriteIECParam;
}

/**
* @brief 参数数量及信息获取处理函数
*
* @param[out] pstSelf
* @param[in] cbGetParamCount， cbGetParamInfo
*/
void CS10x_S_GetParamInfoHandler(CS10xHandle_t pstSelf, CS10x_GetParamCount cbGetParamCount, CS10x_GetParamInfoByIndx cbGetParamInfo)
{
	pstSelf->pfnGetParamCount = cbGetParamCount;
	pstSelf->pfnGetParamInfoByIndx = cbGetParamInfo;
}

/**
 * @brief 读文件
 *
 * @param pstSelf
 * @param cbGetPro
 * @param cbGetNum
 * @param cbRead
 * @param *pvParam
 */
void CS10x_S_FileReadOprtHandler(CS10xHandle_t pstSelf,
                                 CS10x_GetProDirFile cbGetPro,
                                 CS10x_GetNumDirFile cbGetNum,
                                 CS10x_ReadFile cbRead,
                                 void *pvParam)
{
	pstSelf->pfnGetProDirFile = cbGetPro;
	pstSelf->pfnGetNumDirFile = cbGetNum;
	pstSelf->pfnReadFile = cbRead;
	pstSelf->pvFileReadParam = pvParam;
}

/**
 * @brief 写文件
 *
 * @param pstSelf
 * @param cbWrite
 * @param cbCheck
 * @param cbFinish
 * @param *pvParam
 */
void CS10x_S_FileWriteOprtHandler(CS10xHandle_t pstSelf,
                                  CS10x_Write cbWrite,
                                  CS10x_WriteFileCheck cbCheck,
                                  CS10x_WriteFinish cbFinish,
                                  void *pvParam)
{
	pstSelf->pfnWriteFileCheck = cbCheck;
	pstSelf->pfnWrite = cbWrite;
	pstSelf->pfnWriteFinish = cbFinish;
	pstSelf->pvFileWrteParam = pvParam;
}

/**
* @brief 升级处理流程
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_S_UpdateProcHandler(CS10xHandle_t pstSelf, CS10x_UpdateProc cb)
{
	pstSelf->pfnUpdateProc = cb;
}

/**
* @brief 设置计量接口处理
*
* @param[out] pstSelf
* @param[in]  cbSetValue
cbSetDdValue
*/
void CS10x_M_SetDdHandler(CS10xHandle_t pstSelf, CS10x_SetValue cbSetValue, CS10x_SetDdValue cbSetDdValue)
{
	pstSelf->pfnSetValue = cbSetValue;
	pstSelf->pfnSetDdValue = cbSetDdValue;
}

/**
* @brief 设置接收遥控接口
*
* @param[out] pstSelf
* @param[in]  cb
*/
void CS10x_SetYkInforHandler(CS10xHandle_t pstSelf, CS10x_SetYkInfor cb)
{
	pstSelf->pfnSetYkInfor = cb;
}