1.如果结构体中含有指针,在memcpy之前一定要暂存,否则就会覆盖 m_pVPlanResultJogMode void CMotion_Interploation_Interface::CopyJogResult(const PlanInterpFace::structCmdPlanResultData* pStCmdPlanResultData) { //
assert(pStCmdPlanResultData && pStCmdPlanResultData->type == JOG_MODE_PLAN_RESULT);
// m_pVPlanResultJogMode->acc_max
CMotion_interpolation_father* _pOrg = m_pVPlanResultJogMode->ptrVPlan;//暂存插补器ptrVPlan的地址
memcpy(m_pVPlanResultJogMode, pStCmdPlanResultData->ptrVal.ptrVPlanResultJogMode, sizeof(VPlanResultJogMode));//memcpy会将规划结果中的ptrVPlan地址覆盖插补器中ptrVPlan的地址
m_pVPlanResultJogMode->ptrVPlan = _pOrg;//还原原来插补器中ptrVPlan的地址 memcpy(m_pVPlanResultJogMode->ptrVPlan, pStCmdPlanResultData->ptrVal.ptrVPlanResultJogMode->ptrVPlan, sizeof(CS_vel_profile_interp));//给插补器中ptrVPlan的内容进行赋值
}