diff --git a/OutputConst.h b/OutputConst.h index dcc2bb8..97ba635 100644 --- a/OutputConst.h +++ b/OutputConst.h @@ -124,6 +124,17 @@ static const std::string GVAR_R4P = ".R4p" ; // (num) valore pr static const std::string GVAR_R5P = ".R5p" ; // (num) valore precedente del quinto asse rotante static const std::string GVAR_R6P = ".R6p" ; // (num) valore precedente del sesto asse rotante static const std::string GVAR_R7P = ".R7p" ; // (num) valore precedente del settimo asse rotante +static const std::string GVAR_MOVESUCC = ".MOVESUCC" ; // (int) tipo del movimento successivo (0,1,2,3) +static const std::string GVAR_L1S = ".L1s" ; // (num) valore successivo del primo asse lineare +static const std::string GVAR_L2S = ".L2s" ; // (num) valore successivo del secondo asse lineare +static const std::string GVAR_L3S = ".L3s" ; // (num) valore successivo del terzo asse lineare +static const std::string GVAR_R1S = ".R1s" ; // (num) valore successivo del primo asse rotante +static const std::string GVAR_R2S = ".R2s" ; // (num) valore successivo del secondo asse rotante +static const std::string GVAR_R3S = ".R3s" ; // (num) valore successivo del terzo asse rotante +static const std::string GVAR_R4S = ".R4s" ; // (num) valore successivo del quarto asse rotante +static const std::string GVAR_R5S = ".R5s" ; // (num) valore successivo del quinto asse rotante +static const std::string GVAR_R6S = ".R6s" ; // (num) valore successivo del sesto asse rotante +static const std::string GVAR_R7S = ".R7s" ; // (num) valore successivo del settimo asse rotante static const std::string GVAR_L1T = ".L1t" ; // (string) token del primo asse lineare static const std::string GVAR_L2T = ".L2t" ; // (string) token del secondo asse lineare static const std::string GVAR_L3T = ".L3t" ; // (string) token del terzo asse lineare @@ -299,6 +310,36 @@ GetGlobVarAxisPrev( int nAx, const std::string& sVar = GLOB_VAR, bool bIsRobot = } } +//---------------------------------------------------------------------------- +inline std::string +GetGlobVarAxisNext( int nAx, const std::string& sVar = GLOB_VAR, bool bIsRobot = false) +{ + if ( ! bIsRobot) { + switch ( nAx) { + case 1 : return ( sVar + GVAR_L1S) ; + case 2 : return ( sVar + GVAR_L2S) ; + case 3 : return ( sVar + GVAR_L3S) ; + case 4 : return ( sVar + GVAR_R1S) ; + case 5 : return ( sVar + GVAR_R2S) ; + case 6 : return ( sVar + GVAR_R3S) ; + case 7 : return ( sVar + GVAR_R4S) ; + default : return "" ; + } + } + else { + switch ( nAx) { + case 1 : return ( sVar + GVAR_R1S) ; + case 2 : return ( sVar + GVAR_R2S) ; + case 3 : return ( sVar + GVAR_R3S) ; + case 4 : return ( sVar + GVAR_R4S) ; + case 5 : return ( sVar + GVAR_R5S) ; + case 6 : return ( sVar + GVAR_R6S) ; + case 7 : return ( sVar + GVAR_R7S) ; + default : return "" ; + } + } +} + //---------------------------------------------------------------------------- inline std::string GetGlobVarAxisToken( int nAx, bool bIsRobot = false) diff --git a/Processor.cpp b/Processor.cpp index f9451c3..27dd5cc 100644 --- a/Processor.cpp +++ b/Processor.cpp @@ -414,7 +414,7 @@ Processor::ProcessClPath( int nClPathId, int nClPathInd, int nOpId, int nOpInd) // processo l'entità if ( ! ProcessClEnt( nEntId, nEntInd, nClPathId, nClPathInd, nOpId, nOpInd)) bOk = false ; - // passo all'entità successivo + // passo all'entità successiva nEntId = m_pGeomDB->GetNext( nEntId) ; } @@ -449,19 +449,24 @@ Processor::ProcessClEnt( int nEntId, int nEntInd, int nClPathId, int nClPathInd, if ( pCamData == nullptr || pCamData->GetAxesStatus() != CamData::AS_OK) return false ; const DBLVECTOR& AxesEnd = pCamData->GetAxesVal() ; - // Emetto movimento int nMove = pCamData->GetMoveType() ; + // Recupero i dati Cam del movimento successivo del percorso (se esiste) + CamData* pNextCamData = GetCamData( m_pGeomDB->GetUserObj( m_pGeomDB->GetNext( nEntId))) ; + int nMoveNext = ( pNextCamData != nullptr ? pNextCamData->GetMoveType() : -1) ; + DBLVECTOR AxesNull ; + const DBLVECTOR& AxesNext = ( pNextCamData != nullptr ? pNextCamData->GetAxesVal() : AxesNull) ; + // Emetto movimento switch ( nMove) { case 0 : // rapido if ( ! OnRapid( nEntId, nEntInd, nMove, AxesEnd, pCamData->GetAxesMask(), pCamData->GetToolDir(), pCamData->GetCorrDir(), pCamData->GetBackAuxDir(), - pCamData->GetFlag(), pCamData->GetFlag2(), pCamData->GetIndex())) + pCamData->GetFlag(), pCamData->GetFlag2(), pCamData->GetIndex(), nMoveNext, AxesNext)) return false ; break ; case 1 : // linea if ( ! OnLinear( nEntId, nEntInd, nMove, AxesEnd, pCamData->GetToolDir(), pCamData->GetCorrDir(), pCamData->GetBackAuxDir(), - pCamData->GetFeed(), pCamData->GetFlag(), pCamData->GetFlag2(), pCamData->GetIndex())) + pCamData->GetFeed(), pCamData->GetFlag(), pCamData->GetFlag2(), pCamData->GetIndex(), nMoveNext, AxesNext)) return false ; break ; case 2 : // arco CW @@ -471,7 +476,7 @@ Processor::ProcessClEnt( int nEntId, int nEntInd, int nClPathId, int nClPathInd, if ( ! OnArc( nEntId, nEntInd, nMove, AxesEnd, pCamData->GetAxesCen(), ptMid, pCamData->GetAxesRad(), pCamData->GetAxesAngCen(), pCamData->GetToolDir(), pCamData->GetCorrDir(), pCamData->GetBackAuxDir(), - pCamData->GetFeed(), pCamData->GetFlag(), pCamData->GetFlag2(), pCamData->GetIndex())) + pCamData->GetFeed(), pCamData->GetFlag(), pCamData->GetFlag2(), pCamData->GetIndex(), nMoveNext, AxesNext)) return false ; break ; } @@ -974,7 +979,7 @@ Processor::OnPathEndAux( int nInd, const string& sAE) bool Processor::OnRapid( int nEntId, int nEntInd, int nMove, const DBLVECTOR& AxesEnd, int nAxesMask, const Vector3d& vtTool, const Vector3d& vtCorr, const Vector3d& vtAux, - int nFlag, int nFlag2, int nIndex) + int nFlag, int nFlag2, int nIndex, int nMoveNext, const DBLVECTOR& AxesNext) { // cancello variabili estranee ResetArcData() ; @@ -1006,6 +1011,21 @@ Processor::OnRapid( int nEntId, int nEntInd, int nMove, const DBLVECTOR& AxesEnd bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_FLAG2, nFlag2) ; // assegno il valore dell'indice bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_INDEX, nIndex) ; + // anticipazione di alcuni dati dell'eventuale movimento successivo dello stesso percorso + if ( nMoveNext != -1) { + bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVESUCC, nMoveNext) ; + for ( int i = 1 ; i <= MAX_AXES ; ++ i) { + if ( i <= nNumAxes) + bOk = bOk && m_pMachine->LuaSetGlobVar( GetGlobVarAxisNext( i, GLOB_VAR, bIsRobot), AxesNext[i-1]) ; + else + bOk = bOk && m_pMachine->LuaResetGlobVar( GetGlobVarAxisNext( i, GLOB_VAR, bIsRobot)) ; + } + } + else { + bOk = bOk && m_pMachine->LuaResetGlobVar( GLOB_VAR + GVAR_MOVESUCC) ; + for ( int i = 1 ; i <= MAX_AXES ; ++ i) + bOk = bOk && m_pMachine->LuaResetGlobVar( GetGlobVarAxisNext( i, GLOB_VAR, bIsRobot)) ; + } // chiamo la funzione di movimento in rapido bOk = bOk && CallOnRapid() ; return bOk ; @@ -1015,7 +1035,7 @@ Processor::OnRapid( int nEntId, int nEntInd, int nMove, const DBLVECTOR& AxesEnd bool Processor::OnLinear( int nEntId, int nEntInd, int nMove, const DBLVECTOR& AxesEnd, const Vector3d& vtTool, const Vector3d& vtCorr, const Vector3d& vtAux, - double dFeed, int nFlag, int nFlag2, int nIndex) + double dFeed, int nFlag, int nFlag2, int nIndex, int nMoveNext, const DBLVECTOR& AxesNext) { // cancello variabili estranee ResetArcData() ; @@ -1047,6 +1067,21 @@ Processor::OnLinear( int nEntId, int nEntInd, int nMove, const DBLVECTOR& AxesEn bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_FLAG2, nFlag2) ; // assegno il valore dell'indice bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_INDEX, nIndex) ; + // anticipazione di alcuni dati dell'eventuale movimento successivo dello stesso percorso + if ( nMoveNext != -1) { + bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVESUCC, nMoveNext) ; + for ( int i = 1 ; i <= MAX_AXES ; ++ i) { + if ( i <= nNumAxes) + bOk = bOk && m_pMachine->LuaSetGlobVar( GetGlobVarAxisNext( i, GLOB_VAR, bIsRobot), AxesNext[i-1]) ; + else + bOk = bOk && m_pMachine->LuaResetGlobVar( GetGlobVarAxisNext( i, GLOB_VAR, bIsRobot)) ; + } + } + else { + bOk = bOk && m_pMachine->LuaResetGlobVar( GLOB_VAR + GVAR_MOVESUCC) ; + for ( int i = 1 ; i <= MAX_AXES ; ++ i) + bOk = bOk && m_pMachine->LuaResetGlobVar( GetGlobVarAxisNext( i, GLOB_VAR, bIsRobot)) ; + } // chiamo la funzione di movimento in rapido bOk = bOk && CallOnLinear() ; return bOk ; @@ -1057,7 +1092,7 @@ bool Processor::OnArc( int nEntId, int nEntInd, int nMove, const DBLVECTOR& AxesEnd, const Point3d& ptCen, const Point3d& ptMid, double dRad, double dAngCen, const Vector3d& vtTool, const Vector3d& vtCorr, const Vector3d& vtAux, - double dFeed, int nFlag, int nFlag2, int nIndex) + double dFeed, int nFlag, int nFlag2, int nIndex, int nMoveNext, const DBLVECTOR& AxesNext) { // assegno Id e indice entità di movimento bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVEID, nEntId) ; @@ -1099,6 +1134,21 @@ Processor::OnArc( int nEntId, int nEntInd, int nMove, const DBLVECTOR& AxesEnd, bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_FLAG2, nFlag2) ; // assegno il valore dell'indice bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_INDEX, nIndex) ; + // anticipazione di alcuni dati dell'eventuale movimento successivo dello stesso percorso + if ( nMoveNext != -1) { + bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVESUCC, nMoveNext) ; + for ( int i = 1 ; i <= MAX_AXES ; ++ i) { + if ( i <= nNumAxes) + bOk = bOk && m_pMachine->LuaSetGlobVar( GetGlobVarAxisNext( i, GLOB_VAR, bIsRobot), AxesNext[i-1]) ; + else + bOk = bOk && m_pMachine->LuaResetGlobVar( GetGlobVarAxisNext( i, GLOB_VAR, bIsRobot)) ; + } + } + else { + bOk = bOk && m_pMachine->LuaResetGlobVar( GLOB_VAR + GVAR_MOVESUCC) ; + for ( int i = 1 ; i <= MAX_AXES ; ++ i) + bOk = bOk && m_pMachine->LuaResetGlobVar( GetGlobVarAxisNext( i, GLOB_VAR, bIsRobot)) ; + } // chiamo la funzione di movimento in rapido bOk = bOk && CallOnArc() ; return bOk ; diff --git a/Processor.h b/Processor.h index e266f19..1bab9f4 100644 --- a/Processor.h +++ b/Processor.h @@ -61,14 +61,14 @@ class Processor bool OnPathEndAux( int nInd, const std::string& sAE) ; bool OnRapid( int nEntId, int nEntInd, int nMove, const DBLVECTOR& AxesEnd, int nAxesMask, const Vector3d& vtTool, const Vector3d& vtCorr, const Vector3d& vtAux, - int nFlag, int nFlag2, int nIndex) ; + int nFlag, int nFlag2, int nIndex, int nMoveNext, const DBLVECTOR& AxesNext) ; bool OnLinear( int nEntId, int nEntInd, int nMove, const DBLVECTOR& AxesEnd, const Vector3d& vtTool, const Vector3d& vtCorr, const Vector3d& vtAux, - double dFeed, int nFlag, int nFlag2, int nIndex) ; + double dFeed, int nFlag, int nFlag2, int nIndex, int nMoveNext, const DBLVECTOR& AxesNext) ; bool OnArc( int nEntId, int nEntInd, int nMove, const DBLVECTOR& AxesEnd, const Point3d& ptCen, const Point3d& ptMid, double dRad, double dAngCen, const Vector3d& vtTool, const Vector3d& vtCorr, const Vector3d& vtAux, - double dFeed, int nFlag, int nFlag2, int nIndex) ; + double dFeed, int nFlag, int nFlag2, int nIndex, int nMoveNext, const DBLVECTOR& AxesNext) ; bool ResetArcData( void) ; protected : diff --git a/Simulator.cpp b/Simulator.cpp index 4b1c5b9..6769dfb 100644 --- a/Simulator.cpp +++ b/Simulator.cpp @@ -1009,8 +1009,9 @@ Simulator::ManageSingleMove( int& nStatus, double& dMove) // Se inizio di nuova entità if ( m_nEntId != GDB_ID_NULL && m_dCoeff < EPS_ZERO) { ++ m_nEntInd ; + const CamData* pNextCamData = GetCamData( m_pGeomDB->GetUserObj( m_pGeomDB->GetNext( m_nEntId))) ; int nErr ; - if ( ! OnMoveStart( pCamData, nErr)) { + if ( ! OnMoveStart( pCamData, pNextCamData, nErr)) { nStatus = CalcStatusOnError( nErr) ; return false ; } @@ -1933,7 +1934,7 @@ Simulator::OnPathEndAux( int nInd, const string& sAE, int& nErr) //---------------------------------------------------------------------------- bool -Simulator::OnMoveStart( const CamData* pCamData, int& nErr) +Simulator::OnMoveStart( const CamData* pCamData, const CamData* pNextCamData, int& nErr) { // reset stato di errore da script nErr = 0 ; @@ -1965,6 +1966,22 @@ Simulator::OnMoveStart( const CamData* pCamData, int& nErr) bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TDIR, pCamData->GetToolDir()) ; bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_CDIR, pCamData->GetCorrDir()) ; bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_ADIR, pCamData->GetBackAuxDir()) ; + // anticipazione di alcuni dati dell'eventuale movimento successivo dello stesso percorso + if ( pNextCamData != nullptr && pNextCamData->GetAxesStatus() == CamData::AS_OK) { + bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVESUCC, pNextCamData->GetMoveType()) ; + const DBLVECTOR& AxesNext = pNextCamData->GetAxesVal() ; + for ( int i = 1 ; i <= MAX_AXES ; ++ i) { + if ( i <= nNumAxes) + bOk = bOk && m_pMachine->LuaSetGlobVar( GetGlobVarAxisNext( i, GLOB_VAR, bIsRobot), AxesNext[i-1]) ; + else + bOk = bOk && m_pMachine->LuaResetGlobVar( GetGlobVarAxisNext( i, GLOB_VAR, bIsRobot)) ; + } + } + else { + bOk = bOk && m_pMachine->LuaResetGlobVar( GLOB_VAR + GVAR_MOVESUCC) ; + for ( int i = 1 ; i <= MAX_AXES ; ++ i) + bOk = bOk && m_pMachine->LuaResetGlobVar( GetGlobVarAxisNext( i, GLOB_VAR, bIsRobot)) ; + } // reset abilitazione assi attivi bOk = bOk && m_pMachine->LuaResetGlobVar( GLOB_VAR + GVAR_ENABAXES) ; // reset numero assi ausiliari diff --git a/Simulator.h b/Simulator.h index 7fabac9..aeb8fac 100644 --- a/Simulator.h +++ b/Simulator.h @@ -110,7 +110,7 @@ class Simulator const Vector3d& vtExtr, const Point3d& ptMin, const Point3d& ptMax, const DBLVECTOR& vAxMin, const DBLVECTOR& vAxMax, double dElev) ; bool OnPathEnd( int nAE) ; - bool OnMoveStart( const CamData* pCamData, int& nErr) ; + bool OnMoveStart( const CamData* pCamData, const CamData* pNextCamData, int& nErr) ; bool OnMoveEnd( int& nErr) ; bool OnResetMachine( void) ;