📄 specycle.cc
字号:
&returnCode,
&exception);
}
if (pSpeCycle->ParaAxisFlag == 1)
{
end_x=settings->current_x;
end_z= pSpeCycle->AbsValue;
}
else
{
end_z=settings->current_z;
end_x = pSpeCycle->OrdValue;
}
STRAIGHT_FEED(end_x, settings->current_y, end_z
#ifdef AA
,settings->AA_current
#else
#ifdef ALL_AXES
, 0
#endif
#endif
#ifdef BB
, settings->BB_current
#else
#ifdef ALL_AXES
, 0
#endif
#endif
#ifdef CC
, settings->CC_current
#else
#ifdef ALL_AXES
, 0
#endif
#endif
);
settings->current_x SET_TO end_x;
settings->current_z SET_TO end_z;
// DEBUG_PRINT("step 2 STRAIGHT_FEED X %f ,z %f \n", end_x,end_z);
/*
if (!psGlobal->GCode.DyModeSub)
CNC_SetG29Flag(psGlobal);
else
CNC_SetG27Flag(psGlobal);
CNC_SetG01Flag(psGlobal);
*/
pSpeCycle->WorkStep = 3;
break;
}
else
{
if (pSpeCycle->BlockNum<=1)
return NCE_PROF_POINT_INVIALD;
pSpeCycle->BlockNum --;
continue;
}
}
return RS274NGC_OK;
}
/********************************************************************
* Procedure:
* Rapid to return spot by 45 degree angle.
*
********************************************************************/
int PStep3(setup_pointer settings,Special_Cycle *pSpeCycle)
{
//Special_Cycle *pSpeCycle;
ProfBlockStruc Gtl;
PointVar point;
float minvalue;
BYTE limit = 0, direction;
int ret = 0;
//(pMove = &(pResult->Move))->AxisCount = 2;
direction = pSpeCycle->ProfDirection;
//DEBUG_PRINT("pSpeCycle->ProfDirection is %d\n", direction);
//direction=2;
/*
pMove->MoveAxis[0].AxisNo =
(pSpeCycle = pProc->pSpeCycle)->AbsAxisNo - 1;
pMove->MoveAxis[1].AxisNo = pSpeCycle->OrdAxisNo - 1;
pMove->MoveAxis[0].EndPos =
pSpeCycle->CutStep * ZBackDir[pSpeCycle->ParaAxisFlag][direction-1]
+ pSpeCycle->AbsValue;
pMove->MoveAxis[1].EndPos =
pSpeCycle->CutStep * XBackDir[pSpeCycle->ParaAxisFlag][direction-1]
+ pSpeCycle->OrdValue;
*/
/* if (pSpeCycle->ParaAxisFlag == 1)
if (direction == 1 || direction == 4)
{
if(pSpeCycle->AbsMachineValue2 >settings->current_z)
limit = 1;
}
else
{
if(pSpeCycle->AbsMachineValue2 < settings->current_z)
limit = 1;
}
else
if(direction == 1 || direction == 2)
{
if(pSpeCycle->OrdMachineValue2 > settings->current_x)
limit = 1;
}
else
{
if(pSpeCycle->OrdMachineValue2 < settings->current_x)
limit = 1;
}
*/
minvalue = TINY;
// if ( limit )
{
point.PosX=pSpeCycle->CutStep * ZBackDir[pSpeCycle->ParaAxisFlag][direction-1] + pSpeCycle->AbsValue;
point.PosY=pSpeCycle->CutStep * XBackDir[pSpeCycle->ParaAxisFlag][direction-1] + pSpeCycle->OrdValue;
// DEBUG_PRINT("step 3 point x%f ,z %f ----pos 3 %f ------step %f\n", point.PosY,point.PosZ,pSpeCycle->Pos.Element[2],pSpeCycle->CutStep);
CNC_AGLLineOf2Point((PointVar *)&pSpeCycle->AbsValue,
&point,
(LineVar *)&Gtl.CurveExpression,
minvalue,
&ret);
if ( !ret )
CNC_AGLPointOf2Line((LineVar *)&pSpeCycle->Pos,
(LineVar *)&Gtl.CurveExpression,
&point,
minvalue,
&ret);
if ( !ret )
{
STRAIGHT_FEED(point.PosY, settings->current_y, point.PosX
#ifdef AA
,settings->AA_current
#else
#ifdef ALL_AXES
, 0
#endif
#endif
#ifdef BB
, settings->BB_current
#else
#ifdef ALL_AXES
, 0
#endif
#endif
#ifdef CC
, settings->CC_current
#else
#ifdef ALL_AXES
, 0
#endif
#endif
);
settings->current_x SET_TO point.PosY;
settings->current_z SET_TO point.PosX;
// DEBUG_PRINT("step 3 STRAIGHT_TRAVERSE X %f ,z %f \n", point.PosY,point.PosX);
}
}
/*
if (!psGlobal->GCode.DyModeSub)
CNC_SetG29Flag(psGlobal);
else
CNC_SetG27Flag(psGlobal);
CNC_SetG01Flag(psGlobal);
pMove->ProgramF = 1.0;*/
pSpeCycle->WorkStep = 4;
return RS274NGC_OK;
}
/********************************************************************
* Procedure:
* Rapid return to the postion related to
* the original Tool position.
*
********************************************************************/
int PStep4(setup_pointer settings,Special_Cycle *pSpeCycle)
{
//Special_Cycle *pSpeCycle;
//IntMsgStruc *pMove;
int ret = 0;
double end_x;
double end_z;
double cur_pos;
double targe_pos;
// (pMove = &(pResult->Move))->AxisCount = 1;
if (pSpeCycle->ParaAxisFlag == 1)
{
end_z=pSpeCycle->AbsStartValue;
end_x = settings->current_x;
cur_pos=pSpeCycle->OrdValue ;
targe_pos=pSpeCycle->Block[0].Point.PosY;
}
else
{
end_x=pSpeCycle->OrdStartValue;
end_z = settings->current_z;
cur_pos=pSpeCycle->AbsValue;
targe_pos=pSpeCycle->Block[0].Point.PosX;
}
if (pSpeCycle->CutNum == 1 ||cur_pos-pSpeCycle->CutStep <targe_pos)
{
pSpeCycle->ContinuedFlag = 0;
/**Flag = 1;
if (psGlobal->GCode.SpeCycleState == 4)
IO_RestoreFileSite(pSpeCycle->Lcn,
&pProc->pProf->ProfInf[pSpeCycle->ProfNo-1].DpfFPB,
&ret);
else
{
IO_RestoreFileSite(pSpeCycle->Lcn,
&pSpeCycle->RetFPB,
&ret);
if ( !ret )
IO_MoveFilePtr(pSpeCycle->Lcn,
1,
&ret);
}*/
if (pSpeCycle->SPFFlag ==0)
{
fseek(settings->file_pointer,pSpeCycle->RetFPB , SEEK_SET);
settings->sequence_number=pSpeCycle->RetNumber;
settings->SpeCycleState=0;
}
else
{
settings->SpeCycleState=3;
fseek(settings->file_pointer,settings->Prof.ProfInf[pSpeCycle->ProfNo-1].DpfFPB, SEEK_SET);
settings->sequence_number=settings->Prof.ProfInf[pSpeCycle->ProfNo-1].DpfNumber;
settings->prof_abs_offset=pSpeCycle->AbsUOV;
settings->prof_ord_offset=pSpeCycle->OrdUOV;
}
//pProc->pProg_Inf->PostProcessFlag |= 0x20;
}
else
{
pSpeCycle->WorkStep = 1;
pSpeCycle->CutNum --;
}
STRAIGHT_TRAVERSE(end_x, settings->current_y, end_z
#ifdef AA
,settings->AA_current
#else
#ifdef ALL_AXES
, 0
#endif
#endif
#ifdef BB
, settings->BB_current
#else
#ifdef ALL_AXES
, 0
#endif
#endif
#ifdef CC
, settings->CC_current
#else
#ifdef ALL_AXES
, 0
#endif
#endif
);
settings->current_x SET_TO end_x;
settings->current_z SET_TO end_z;
//DEBUG_PRINT("step 4 STRAIGHT_TRAVERSE X %f ,z %f \n", end_x,end_z);
/*if (pSpeCycle->ContinuedFlag == 0)
{
end_x=pSpeCycle->OrdMachineValue2;
end_z=pSpeCycle->AbsMachineValue2;
STRAIGHT_TRAVERSE(end_x, settings->current_y, end_z
#ifdef AA
,settings->AA_current
#else
#ifdef ALL_AXES
, 0
#endif
#endif
#ifdef BB
, settings->BB_current
#else
#ifdef ALL_AXES
, 0
#endif
#endif
#ifdef CC
, settings->CC_current
#else
#ifdef ALL_AXES
, 0
#endif
#endif
);
settings->current_x SET_TO end_x;
settings->current_z SET_TO end_z;
}*/
/*
if (!psGlobal->GCode.DyModeSub)
CNC_SetG29Flag(psGlobal);
else
CNC_SetG27Flag(psGlobal);
CNC_SetG01Flag(psGlobal);
pMove->ProgramF = 1.0;*/
return RS274NGC_OK;
}
/********************************************************************
* Procedure:
* The Main Control of Parallel axis machining
*
********************************************************************/
int CNC_MainProgOfSpeCylce(setup_pointer settings,Special_Cycle *pSpeCycle)
{
static char name[] SET_TO "CNC_MainProgOfSpeCylce";
int status = 0;
int cut_num;
//DEBUG_PRINT("pSpeCycle->BlockNum IS %d\n", pSpeCycle->BlockNum);
cut_num=pSpeCycle->CutNum;
while(pSpeCycle->ContinuedFlag )
{
switch(pSpeCycle->WorkStep )
{
case 0:
CHP(PStep0(settings,pSpeCycle));
cut_num=pSpeCycle->CutNum;
//DEBUG_PRINT("PStep return %d\n",ret);
break;
case 1:
CHP(PStep1(settings,pSpeCycle));
break;
case 2:
CHP(PStep2(settings,pSpeCycle));
break;
case 3:
CHP(PStep3(settings,pSpeCycle));
break;
case 4:
CHP(PStep4(settings,pSpeCycle));
//DEBUG_PRINT("id %d ,line %d\n",settings->display_sequence_number,pSpeCycle->Block[pSpeCycle->BlockNum-1].sequence_number);
break;
default:
break;
if ( !status )
{
/*
CNC_ComputeLineIntInfo(pProc->pAxis_Arg->IntAxis,
pProc->pWork_Inf,
pProc->pMeasureInf,
&pResult->Move,
pMoveBit,
pResult);
pResult->Error = 0xFFFF;*/
}
//return status;
}
//DEBUG_PRINT("new %d ,old %d\n",pSpeCycle->CutNum,cut_num);
if (pSpeCycle->CutNum<cut_num)
{
return RS274NGC_OK;
}
}
return RS274NGC_OK;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -