diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index d6167a9..8100120 100644 Binary files a/EgtMachKernel.rc and b/EgtMachKernel.rc differ diff --git a/Generator.cpp b/Generator.cpp index 9fe87df..f0c4b5b 100644 --- a/Generator.cpp +++ b/Generator.cpp @@ -29,7 +29,6 @@ using namespace std ; //---------------------------------------------------------------------------- static const string ERR_EXT = ".err" ; -static const int MAX_AXES = 7 ; //---------------------------------------------------------------------------- Generator::Generator( void) @@ -697,51 +696,3 @@ Generator::ResetArcData( void) bOk = bOk && m_pMachine->LuaResetGlobVar( GLOB_VAR + GVAR_AC) ; return bOk ; } - -//---------------------------------------------------------------------------- -string -Generator::GetGlobVarAxisValue( int nAx) -{ - switch ( nAx) { - case 1 : return ( GLOB_VAR + GVAR_L1) ; - case 2 : return ( GLOB_VAR + GVAR_L2) ; - case 3 : return ( GLOB_VAR + GVAR_L3) ; - case 4 : return ( GLOB_VAR + GVAR_R1) ; - case 5 : return ( GLOB_VAR + GVAR_R2) ; - case 6 : return ( GLOB_VAR + GVAR_R3) ; - case 7 : return ( GLOB_VAR + GVAR_R4) ; - default : return "" ; - } -} - -//---------------------------------------------------------------------------- -string -Generator::GetGlobVarAxisPrev( int nAx) -{ - switch ( nAx) { - case 1 : return ( GLOB_VAR + GVAR_L1P) ; - case 2 : return ( GLOB_VAR + GVAR_L2P) ; - case 3 : return ( GLOB_VAR + GVAR_L3P) ; - case 4 : return ( GLOB_VAR + GVAR_R1P) ; - case 5 : return ( GLOB_VAR + GVAR_R2P) ; - case 6 : return ( GLOB_VAR + GVAR_R3P) ; - case 7 : return ( GLOB_VAR + GVAR_R4P) ; - default : return "" ; - } -} - -//---------------------------------------------------------------------------- -string -Generator::GetGlobVarAxisToken( int nAx) -{ - switch ( nAx) { - case 1 : return ( GLOB_VAR + GVAR_L1T) ; - case 2 : return ( GLOB_VAR + GVAR_L2T) ; - case 3 : return ( GLOB_VAR + GVAR_L3T) ; - case 4 : return ( GLOB_VAR + GVAR_R1T) ; - case 5 : return ( GLOB_VAR + GVAR_R2T) ; - case 6 : return ( GLOB_VAR + GVAR_R3T) ; - case 7 : return ( GLOB_VAR + GVAR_R4T) ; - default : return "" ; - } -} diff --git a/Generator.h b/Generator.h index 07b1bb4..1640711 100644 --- a/Generator.h +++ b/Generator.h @@ -57,9 +57,6 @@ class Generator bool OnArc( int nMove, const DBLVECTOR& AxesEnd, const Point3d& ptCen, double dRad, double dAngCen, double dFeed, int nFlag) ; bool ResetArcData( void) ; - std::string GetGlobVarAxisValue( int nAx) ; - std::string GetGlobVarAxisPrev( int nAx) ; - std::string GetGlobVarAxisToken( int nAx) ; private : MachMgr* m_pMchMgr ; // puntatore al gestore di tutte le lavorazioni diff --git a/MachMgr.h b/MachMgr.h index d92c20f..8b68bed 100644 --- a/MachMgr.h +++ b/MachMgr.h @@ -257,6 +257,8 @@ class MachMgr : public IMachMgr bool ResetAxisPos( const std::string& sAxis) override ; bool ResetAllAxesPos( void) override ; bool LoadTool( const std::string& sHead, int nExit, const std::string& sTool) override ; + bool GetLoadedTool( const std::string& sHead, int nExit, std::string& sTool) override ; + bool UnloadTool( const std::string& sHead, int nExit) override ; bool ResetHeadSet( const std::string& sHead) override ; bool SetMachineLook( int nFlag) override ; diff --git a/MachMgrMachines.cpp b/MachMgrMachines.cpp index df452a4..4e5ac61 100644 --- a/MachMgrMachines.cpp +++ b/MachMgrMachines.cpp @@ -221,6 +221,22 @@ MachMgr::LoadTool( const string& sHead, int nExit, const string& sTool) return ( ( pMch != nullptr) ? pMch->LoadTool( sHead, nExit, sTool) : false) ; } +//---------------------------------------------------------------------------- +bool +MachMgr::GetLoadedTool( const string& sHead, int nExit, string& sTool) +{ + Machine* pMch = GetCurrMachine() ; + return ( ( pMch != nullptr) ? pMch->GetLoadedTool( sHead, nExit, sTool) : false) ; +} + +//---------------------------------------------------------------------------- +bool +MachMgr::UnloadTool( const string& sHead, int nExit) +{ + Machine* pMch = GetCurrMachine() ; + return ( ( pMch != nullptr) ? pMch->UnloadTool( sHead, nExit) : false) ; +} + //---------------------------------------------------------------------------- bool MachMgr::ResetHeadSet( const string& sHead) diff --git a/Machine.h b/Machine.h index 1691276..1e62047 100644 --- a/Machine.h +++ b/Machine.h @@ -52,6 +52,8 @@ class Machine return ( IsHeadGroup( nId) ? nId : GDB_ID_NULL) ; } bool SetLook( int nFlag) ; bool LoadTool( const std::string& sHead, int nExit, const std::string& sTool) ; + bool GetLoadedTool( const std::string& sHead, int nExit, std::string& sTool) ; + bool UnloadTool( const string& sHead, int nExit) ; bool ResetHeadSet( const std::string& sHead) ; bool SetAxisPos( const std::string& sAxis, double dVal) ; bool GetAxisPos( const std::string& sAxis, double& dVal) const ; diff --git a/MachineHeads.cpp b/MachineHeads.cpp index 6556639..ed9aa1a 100644 --- a/MachineHeads.cpp +++ b/MachineHeads.cpp @@ -73,6 +73,51 @@ Machine::LoadTool( const string& sHead, int nExit, const string& sTool) return EnableHeadInSet( sHead) ; } +//---------------------------------------------------------------------------- +bool +Machine::GetLoadedTool( const string& sHead, int nExit, string& sTool) +{ + // controllo GeomDB + if ( m_pGeomDB == nullptr) + return false ; + // recupero il gruppo della testa + int nHdGrp = GetGroup( sHead) ; + if ( ! IsHeadGroup( nHdGrp)) + return false ; + // cerco il gruppo dell'uscita in quello della testa + string sExit = MCH_EXIT + ToString( nExit) ; + int nExGrp = m_pGeomDB->GetFirstNameInGroup( nHdGrp, sExit) ; + Exit* pExit = GetExit( nExGrp) ; + if ( pExit == nullptr) + return false ; + // recupero nome utensile montato + sTool = pExit->GetTool() ; + return ( ! sTool.empty()) ; +} + +//---------------------------------------------------------------------------- +bool +Machine::UnloadTool( const string& sHead, int nExit) +{ + // controllo GeomDB + if ( m_pGeomDB == nullptr) + return false ; + // recupero il gruppo della testa + int nHdGrp = GetGroup( sHead) ; + if ( ! IsHeadGroup( nHdGrp)) + return false ; + // cerco il gruppo dell'uscita in quello della testa + string sExit = MCH_EXIT + ToString( nExit) ; + int nExGrp = m_pGeomDB->GetFirstNameInGroup( nHdGrp, sExit) ; + Exit* pExit = GetExit( nExGrp) ; + if ( pExit == nullptr) + return false ; + // pulisco il gruppo dell'uscita + m_pGeomDB->EmptyGroup( nExGrp) ; + pExit->SetTool( "") ; + return true ; +} + //---------------------------------------------------------------------------- bool Machine::ResetHeadSet( const string& sHead) diff --git a/MachiningConst.h b/MachiningConst.h index 7a0cc49..5f0f679 100644 --- a/MachiningConst.h +++ b/MachiningConst.h @@ -53,7 +53,8 @@ GetMachiningTitle( int nMchType) "Milling", "Pocketing", "Mortising", - "SawRoughing"} ; + "SawRoughing", + "SawFinishing"} ; switch ( nMchType) { case MT_DRILLING : return MchTitle[1] ; case MT_SAWING : return MchTitle[2] ; @@ -61,6 +62,7 @@ GetMachiningTitle( int nMchType) case MT_POCKETING : return MchTitle[4] ; case MT_MORTISING : return MchTitle[5] ; case MT_SAWROUGHING : return MchTitle[6] ; + case MT_SAWFINISHING : return MchTitle[7] ; } return MchTitle[0] ; } diff --git a/MachiningsMgr.cpp b/MachiningsMgr.cpp index cf51c88..4d6666b 100644 --- a/MachiningsMgr.cpp +++ b/MachiningsMgr.cpp @@ -420,6 +420,7 @@ MachiningsMgr::SaveGeneral( Writer& TheWriter) const sOut = MF_HOLEDTOL + "=" + ToString( m_dHoleDiamToler) ; bOk = bOk && TheWriter.OutText( sOut) ; sOut = MF_EXTSAWARCMINRAD + "=" + ToString( m_dExtSawArcMinRad) ; + bOk = bOk && TheWriter.OutText( sOut) ; return bOk ; } diff --git a/Operation.cpp b/Operation.cpp index b2bf200..b593040 100644 --- a/Operation.cpp +++ b/Operation.cpp @@ -739,20 +739,25 @@ Operation::AdjustStartEndMovements(void) if ( pPrevOp != nullptr) sPrevTool = pPrevOp->GetToolName() ; - // imposto l'utensile per i calcoli macchina - if ( ! m_pMchMgr->SetCalcTool( GetToolName(), GetHeadName(), GetExitNbr())) - return false ; - // determino posizione precedente assi DBLVECTOR vAxVal ; // se primo utensile, uso la posizione home if ( sPrevTool.empty()) { + // imposto l'utensile per i calcoli macchina + if ( ! m_pMchMgr->SetCalcTool( GetToolName(), GetHeadName(), GetExitNbr())) + return false ; + // recupero posizione home if ( ! m_pMchMgr->GetAllCalcAxesHomePos( vAxVal)) return false ; } // se utensile non cambiato o su diversa uscita della stessa testa, uso posizione finale della lavorazione precedente else if ( ! ToolChangeNeeded( *pPrevOp, *this)) { + // imposto l'utensile per i calcoli macchina + if ( ! m_pMchMgr->SetCalcTool( GetToolName(), GetHeadName(), GetExitNbr())) + return false ; + // cancello risalita lavorazione precedente pPrevOp->RemoveRise() ; + // recupero posizioni DBLVECTOR vAxIni ; if ( ! pPrevOp->GetFinalAxesValues( vAxVal) || ! GetInitialAxesValues( vAxIni)) return false ; @@ -769,9 +774,16 @@ Operation::AdjustStartEndMovements(void) } // altrimenti aggiungo uscita per cambio utensile alla lavorazione precedente e parto da questa else { + // imposto l'utensile precedente per i calcoli macchina + if ( ! m_pMchMgr->SetCalcTool( pPrevOp->GetToolName(), pPrevOp->GetHeadName(), pPrevOp->GetExitNbr())) + return false ; + // ricalcolo risalita di lavorazione precedente pPrevOp->RemoveRise() ; if ( ! pPrevOp->AddRise( vAxVal)) return false ; + // imposto l'utensile per i calcoli macchina + if ( ! m_pMchMgr->SetCalcTool( GetToolName(), GetHeadName(), GetExitNbr())) + return false ; } // aggiusto l'inizio di ogni percorso di lavoro @@ -917,10 +929,11 @@ Operation::AddRise( DBLVECTOR& vAxVal, double dDelta) double dL1 = vAxVal[0] ; double dL2 = vAxVal[1] ; double dL3 = vAxVal[2] ; - double dR1 = ( vAxVal.size() >= 4 ? vAxVal[3] : 0) ; - double dR2 = ( vAxVal.size() >= 5 ? vAxVal[4] : 0) ; + DBLVECTOR vAng ; + for ( int i = 0 ; i < int( vAxVal.size()) - 3 ; ++ i) + vAng.emplace_back( vAxVal[i+3]) ; int nStat ; - bool bOk = ( m_pMchMgr->VerifyOutstroke( dL1, dL2, dL3, dR1, dR2, nStat) && nStat == 0) ; + bool bOk = ( m_pMchMgr->VerifyOutstroke( dL1, dL2, dL3, vAng, nStat) && nStat == 0) ; // assegno i dati pCam->SetAxes( (bOk ? CamData::AS_OK : CamData::AS_OUTSTROKE), vAxVal) ; pCam->SetMoveType( 0) ; diff --git a/OutputConst.h b/OutputConst.h index 5753640..a5d17c8 100644 --- a/OutputConst.h +++ b/OutputConst.h @@ -16,6 +16,8 @@ #include //---------------------------------------------------------------------------- +// Massimo numero di assi macchina attivi +static const int MAX_AXES = 7 ; // Variabili static const std::string GLOB_VAR = "EMT" ; // tavola variabili globali static const std::string GVAR_USETO1 = ".USETO1" ; // (bool) flag per utilizzo origine tavola @@ -47,6 +49,8 @@ static const std::string GVAR_RAWTYPE = ".RAWTYPE" ; // (int) tipo di mo static const std::string GVAR_RAWPOS = ".RAWPOS" ; // (Point3d) posizione di movimento del grezzo static const std::string GVAR_RAWFLAG = ".RAWFLAG" ; // (int) flag per movimento del grezzo static const std::string GVAR_TOOL = ".TOOL" ; // (string) nome utensile +static const std::string GVAR_HEAD = ".HEAD" ; // (string) nome testa +static const std::string GVAR_EXIT = ".EXIT" ; // (int) indice uscita static const std::string GVAR_MCHID = ".MCHID" ; // (int) identificativo lavorazione static const std::string GVAR_MCHIND = ".MCHIND" ; // (int) indice lavorazione static const std::string GVAR_PATHID = ".PATHID" ; // (int) identificativo percorso di lavorazione @@ -86,6 +90,10 @@ static const std::string GVAR_C3T = ".C3t" ; // (num) token del static const std::string GVAR_RRT = ".RRt" ; // (num) token del raggio per arco static const std::string GVAR_MASK = ".MASK" ; // (int) mask associato ai movimenti in rapido static const std::string GVAR_FLAG = ".FLAG" ; // (int) flag associato ad ogni movimento +static const std::string GVAR_AUXAXES = ".AuxAxes" ; // (int) numero assi ausiliari per simulazione +static const std::string GVAR_AN = ".AN" ; // (num) valore del N-esimo asse ausiliario per simulazione +static const std::string GVAR_ANT = ".ANt" ; // (string) token del N-esimo asse ausiliario per simulazione + // Funzioni generazione static const std::string ON_START = "OnStart" ; static const std::string ON_END = "OnEnd" ; @@ -117,4 +125,53 @@ static const std::string ON_SIMUL_MOVE_END = "OnSimulMoveEnd" ; // Funzioni macchina static const std::string ON_RESET_MACHINE = "OnResetMachine" ; // Valore minimo flag per chiamata funzione di movimento in simulazione -static const int MIN_CALL_SIMUL_MOVE = 1000 ; \ No newline at end of file +static const int MIN_CALL_SIMUL_MOVE = 1000 ; + + +//---------------------------------------------------------------------------- +inline std::string +GetGlobVarAxisValue( int nAx) +{ + switch ( nAx) { + case 1 : return ( GLOB_VAR + GVAR_L1) ; + case 2 : return ( GLOB_VAR + GVAR_L2) ; + case 3 : return ( GLOB_VAR + GVAR_L3) ; + case 4 : return ( GLOB_VAR + GVAR_R1) ; + case 5 : return ( GLOB_VAR + GVAR_R2) ; + case 6 : return ( GLOB_VAR + GVAR_R3) ; + case 7 : return ( GLOB_VAR + GVAR_R4) ; + default : return "" ; + } +} + +//---------------------------------------------------------------------------- +inline std::string +GetGlobVarAxisPrev( int nAx) +{ + switch ( nAx) { + case 1 : return ( GLOB_VAR + GVAR_L1P) ; + case 2 : return ( GLOB_VAR + GVAR_L2P) ; + case 3 : return ( GLOB_VAR + GVAR_L3P) ; + case 4 : return ( GLOB_VAR + GVAR_R1P) ; + case 5 : return ( GLOB_VAR + GVAR_R2P) ; + case 6 : return ( GLOB_VAR + GVAR_R3P) ; + case 7 : return ( GLOB_VAR + GVAR_R4P) ; + default : return "" ; + } +} + +//---------------------------------------------------------------------------- +inline std::string +GetGlobVarAxisToken( int nAx) +{ + switch ( nAx) { + case 1 : return ( GLOB_VAR + GVAR_L1T) ; + case 2 : return ( GLOB_VAR + GVAR_L2T) ; + case 3 : return ( GLOB_VAR + GVAR_L3T) ; + case 4 : return ( GLOB_VAR + GVAR_R1T) ; + case 5 : return ( GLOB_VAR + GVAR_R2T) ; + case 6 : return ( GLOB_VAR + GVAR_R3T) ; + case 7 : return ( GLOB_VAR + GVAR_R4T) ; + default : return "" ; + } +} diff --git a/Simulator.cpp b/Simulator.cpp index af157d3..cff2510 100644 --- a/Simulator.cpp +++ b/Simulator.cpp @@ -260,17 +260,10 @@ Simulator::Move( int& nStatus) } // Se inizio di nuova entità - if ( m_nEntId != GDB_ID_NULL && m_dCoeff < EPS_ZERO) { - ++ m_nEntInd ; - // richiamo gestione evento inizio entità - if ( ! OnMoveStart()) { - nStatus = MCH_SIM_ERR ; - return false ; - } - } + bool bNewEnt = ( m_nEntId != GDB_ID_NULL && m_dCoeff < EPS_ZERO) ; - // Cerco prossima posizione su interpolazione corrente - CamData* pCamData = GetCamData( m_pGeomDB->GetUserObj( m_nEntId)) ; + // Recupero posizione finale + const CamData* pCamData = GetCamData( m_pGeomDB->GetUserObj( m_nEntId)) ; if ( pCamData == nullptr) { nStatus = MCH_SIM_ERR ; return false ; @@ -297,6 +290,17 @@ Simulator::Move( int& nStatus) const DBLVECTOR& AxesEnd = pCamData->GetAxesVal() ; // Tipo di movimento int nMoveType = pCamData->GetMoveType() ; + + // Eventuale gestione evento inizio entità + if ( bNewEnt) { + ++ m_nEntInd ; + if ( ! OnMoveStart( pCamData)) { + nStatus = MCH_SIM_ERR ; + return false ; + } + bNewEnt = false ; + } + // Calcolo distanza di movimento double dSqDist = 0 ; for ( size_t i = 0 ; i < m_AxesName.size() ; ++ i) { @@ -308,6 +312,7 @@ Simulator::Move( int& nStatus) m_dCoeff += ( nMoveType == 0 ? 4 : 1) * m_dStep / dDist ; if ( m_dCoeff > 1) m_dCoeff = 1 ; + // Eseguo movimento rapido o lineare if ( nMoveType != 2 && nMoveType != 3) { for ( size_t i = 0 ; i < m_AxesName.size() ; ++ i) { @@ -331,6 +336,12 @@ Simulator::Move( int& nStatus) } } + // Muovo eventuali assi ausiliari + for ( size_t i = 0 ; i < m_AuxAxesName.size() ; ++ i) { + double dVal = m_AuxAxesVal[i] * ( 1 - m_dCoeff) + m_AuxAxesEnd[i] * m_dCoeff ; + m_pMachine->SetAxisPos( m_AuxAxesName[i], dVal) ; + } + // Se arrivato a fine interpolazione movimento, salvo posizioni e segnalo if ( m_dCoeff > 0.999) { for ( size_t i = 0 ; i < m_AxesName.size() ; ++ i) @@ -469,6 +480,11 @@ Simulator::UpdateTool( bool bForced) if ( ! m_pMchMgr->SetCalcTool( sTool, sHead, nExit)) return false ; m_sTool = sTool ; + // imposto variabili per script + if ( ! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TOOL, m_sTool) || + ! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_HEAD, sHead) || + ! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_EXIT, nExit)) + return false ; } return true ; } @@ -482,6 +498,11 @@ Simulator::UpdateTool( bool bForced) if ( ! m_pMchMgr->SetCalcTool( sTool, sHead, nExit)) return false ; m_sTool = sTool ; + // imposto variabili per script + if ( ! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TOOL, m_sTool) || + ! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_HEAD, sHead) || + ! m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_EXIT, nExit)) + return false ; return true ; } return false ; @@ -566,7 +587,7 @@ Simulator::OnMachiningStart( int nOpId, int nOpInd) // verifico esistenza funzione if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_MACHINING_START)) return true ; - // assegno identificativo e indice disposizione + // assegno identificativo e indice lavorazione bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MCHID, nOpId) ; bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MCHIND, nOpInd) ; // chiamo la funzione di inizio disposizione @@ -615,25 +636,65 @@ Simulator::OnPathEnd( void) //---------------------------------------------------------------------------- bool -Simulator::OnMoveStart( void) +Simulator::OnMoveStart( const CamData* pCamData) { - // verifico richiesta chiamata funzione - CamData* pCamData = GetCamData( m_pGeomDB->GetUserObj( m_nEntId)) ; - if ( pCamData == nullptr) - return false ; - int nFlag = pCamData->GetFlag() ; - if ( nFlag < MIN_CALL_SIMUL_MOVE) - return true ; - // assegno dati + // pulisco dati assi ausiliari + m_AuxAxesName.clear() ; + m_AuxAxesVal.clear() ; + m_AuxAxesEnd.clear() ; + + // recupero e assegno i dati + // dati generali bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVEID, m_nEntId) ; bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVEIND, m_nEntInd) ; bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVE, pCamData->GetMoveType()) ; - bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_FLAG, nFlag) ; + bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_FLAG, pCamData->GetFlag()) ; + // valore degli assi all'inizio e alla fine del movimento + int nNumAxes = int( m_AxesName.size()) ; + const DBLVECTOR& AxesEnd = pCamData->GetAxesVal() ; + for ( int i = 1 ; i <= MAX_AXES ; ++ i) { + if ( i <= nNumAxes) { + bOk = bOk && m_pMachine->LuaSetGlobVar( GetGlobVarAxisPrev(i), m_AxesVal[i-1]) ; + bOk = bOk && m_pMachine->LuaSetGlobVar( GetGlobVarAxisValue(i), AxesEnd[i-1]) ; + } + else { + bOk = bOk && m_pMachine->LuaResetGlobVar( GetGlobVarAxisPrev(i)) ; + bOk = bOk && m_pMachine->LuaResetGlobVar( GetGlobVarAxisValue(i)) ; + } + } + // reset numero assi ausiliari + bOk = bOk && m_pMachine->LuaResetGlobVar( GLOB_VAR + GVAR_AUXAXES) ; + // verifico esistenza funzione if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_MOVE_START)) return true ; // chiamo la funzione bOk = bOk && m_pMachine->LuaCallFunction( ON_SIMUL_MOVE_START) ; + if ( ! bOk) + return false ; + + // recupero i dati di ritorno + int nNumAuxAxes = 0 ; + if ( ! m_pMachine->LuaGetGlobVar( GLOB_VAR + GVAR_AUXAXES, nNumAuxAxes) || nNumAuxAxes == 0) + return true ; + m_AuxAxesName.reserve( nNumAuxAxes) ; + m_AuxAxesVal.reserve( nNumAuxAxes) ; + m_AuxAxesEnd.reserve( nNumAuxAxes) ; + for ( int i = 1 ; i <= nNumAuxAxes && bOk ; ++ i) { + string sName ; double dVal ; double dEnd ; + string sAuxAxVal = GLOB_VAR + GVAR_AN ; ReplaceString( sAuxAxVal, "N", ToString( i)) ; + string sAuxAxTok = GLOB_VAR + GVAR_ANT ; ReplaceString( sAuxAxTok, "N", ToString( i)) ; + if ( m_pMachine->LuaGetGlobVar( sAuxAxTok, sName) && + m_pMachine->GetAxisPos( sName, dVal) && + m_pMachine->LuaGetGlobVar( sAuxAxVal, dEnd)) { + m_AuxAxesName.emplace_back( sName) ; + m_AuxAxesVal.emplace_back( dVal) ; + m_AuxAxesEnd.emplace_back( dEnd) ; + } + else + bOk = false ; + } + return bOk ; } @@ -641,13 +702,6 @@ Simulator::OnMoveStart( void) bool Simulator::OnMoveEnd( void) { - // verifico richiesta chiamata funzione - CamData* pCamData = GetCamData( m_pGeomDB->GetUserObj( m_nEntId)) ; - if ( pCamData == nullptr) - return false ; - int nFlag = pCamData->GetFlag() ; - if ( nFlag < MIN_CALL_SIMUL_MOVE) - return true ; // verifico esistenza funzione if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_MOVE_END)) return true ; diff --git a/Simulator.h b/Simulator.h index fa1d7a4..f6d2b8b 100644 --- a/Simulator.h +++ b/Simulator.h @@ -48,7 +48,7 @@ class Simulator bool OnMachiningEnd( void) ; bool OnPathStart( int nClPathId, int nClPathInd) ; bool OnPathEnd( void) ; - bool OnMoveStart( void) ; + bool OnMoveStart( const CamData* pCamData) ; bool OnMoveEnd( void) ; bool OnResetMachine( void) ; @@ -67,4 +67,7 @@ class Simulator std::string m_sTool ; // nome dell'utensile corrente STRVECTOR m_AxesName ; // nomi degli assi macchina attivi DBLVECTOR m_AxesVal ; // valori degli assi macchina all'inizio del movimento corrente + STRVECTOR m_AuxAxesName ; // nomi degli assi macchina ausiliari abilitati + DBLVECTOR m_AuxAxesVal ; // valori degli assi macchina ausiliari all'inizio del movimento corrente + DBLVECTOR m_AuxAxesEnd ; // valori degli assi macchina ausiliari alla fine del movimento corrente } ;