diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index d305131..87ff2dc 100644 Binary files a/EgtMachKernel.rc and b/EgtMachKernel.rc differ diff --git a/Generator.cpp b/Generator.cpp index 4baf8e6..62af49d 100644 --- a/Generator.cpp +++ b/Generator.cpp @@ -499,7 +499,7 @@ Generator::OnProgramEnd( void) bool Generator::ProcessToolData( void) { - struct ToolData { + struct MyToolData { string sName ; string sHead ; int nExit ; @@ -507,10 +507,11 @@ Generator::ProcessToolData( void) int nComp ; double dDiam ; double dLen ; - ToolData( void) - : sName(), sHead(), nExit( 0), sTcPos(), nComp(0), dDiam( 0), dLen( 0) {} + double dMaxSpeed ; + MyToolData( void) + : sName(), sHead(), nExit( 0), sTcPos(), nComp(0), dDiam( 0), dLen( 0), dMaxSpeed( 0) {} } ; - typedef vector TDATAVECTOR ; + typedef vector TDATAVECTOR ; TDATAVECTOR vTdata ; // ciclo sulle lavorazioni per ricavare gli utensili utilizzati int nOpId = m_pMchMgr->GetFirstActiveOperation() ; @@ -526,7 +527,7 @@ Generator::ProcessToolData( void) if ( ! m_pMchMgr->GetMachiningParam( MPA_TOOL, sTool)) return false ; // Recupero i dati dell'utensile - ToolData Tdata ; + MyToolData Tdata ; if ( m_pMchMgr->TdbSetCurrTool( sTool)) { Tdata.sName = sTool ; m_pMchMgr->TdbGetCurrToolParam( TPA_HEAD, Tdata.sHead) ; @@ -535,6 +536,7 @@ Generator::ProcessToolData( void) m_pMchMgr->TdbGetCurrToolParam( TPA_CORR, Tdata.nComp) ; m_pMchMgr->TdbGetCurrToolParam( TPA_DIAM, Tdata.dDiam) ; m_pMchMgr->TdbGetCurrToolParam( TPA_LEN, Tdata.dLen) ; + m_pMchMgr->TdbGetCurrToolParam( TPA_MAXSPEED, Tdata.dMaxSpeed) ; vTdata.push_back( Tdata) ; } } @@ -542,7 +544,7 @@ Generator::ProcessToolData( void) nOpId = m_pMchMgr->GetNextActiveOperation( nOpId) ; } // ordino l'elenco degli utensili - std::sort( vTdata.begin(), vTdata.end(), []( const ToolData& a, const ToolData& b) + std::sort( vTdata.begin(), vTdata.end(), []( const MyToolData& a, const MyToolData& b) { if ( a.sHead == b.sHead) return a.nExit < b.nExit ; else @@ -561,6 +563,7 @@ Generator::ProcessToolData( void) bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TCOMP, vTdata[i].nComp) ; bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TDIAM, vTdata[i].dDiam) ; bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TLEN, vTdata[i].dLen) ; + bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_SMAX, vTdata[i].dMaxSpeed) ; // se esiste, chiamo la funzione di emissione dati utensile if ( m_pMachine->LuaExistsFunction( ON_TOOL_DATA)) bOk = bOk && m_pMachine->LuaCallFunction( ON_TOOL_DATA) ; diff --git a/MachMgr.h b/MachMgr.h index 1ac86fd..94f101e 100644 --- a/MachMgr.h +++ b/MachMgr.h @@ -235,7 +235,7 @@ class MachMgr : public IMachMgr // Simulation bool SimStart( void) override ; bool SimMove( int& nStatus) override ; - bool SimGetAxisInfoPos( int nI, std::string& sToken, double& dVal) override ; + bool SimGetAxisInfoPos( int nI, std::string& sToken, bool& bLinear, double& dVal) override ; bool SimGetToolInfo( std::string& sName, double& dSpeed) override ; bool SimGetMoveInfo( int& nGmove, double& dFeed) override ; bool SimSetStep( double dStep) override ; diff --git a/MachMgrSimulation.cpp b/MachMgrSimulation.cpp index fb287ba..40da572 100644 --- a/MachMgrSimulation.cpp +++ b/MachMgrSimulation.cpp @@ -52,13 +52,13 @@ MachMgr::SimMove( int& nStatus) //---------------------------------------------------------------------------- bool -MachMgr::SimGetAxisInfoPos( int nI, string& sToken, double& dVal) +MachMgr::SimGetAxisInfoPos( int nI, string& sToken, bool& bLinear, double& dVal) { // verifico simulatore if ( m_pSimul == nullptr) return false ; - // recupero quote - return m_pSimul->GetAxisInfoPos( nI, sToken, dVal) ; + // recupero dati + return m_pSimul->GetAxisInfoPos( nI, sToken, bLinear, dVal) ; } //---------------------------------------------------------------------------- diff --git a/Machine.h b/Machine.h index 42ec076..0a0ca25 100644 --- a/Machine.h +++ b/Machine.h @@ -55,6 +55,8 @@ class Machine bool GetLoadedTool( const std::string& sHead, int nExit, std::string& sTool) const ; bool UnloadTool( const string& sHead, int nExit) ; bool ResetHeadSet( const std::string& sHead) ; + bool GetAxisToken( const std::string& sAxis, std::string& sToken) const ; + bool GetAxisType( const string& sAxis, bool& bLinear) const ; bool SetAxisPos( const std::string& sAxis, double dVal) ; bool GetAxisPos( const std::string& sAxis, double& dVal) const ; bool GetAxisHomePos( const std::string& sAxis, double& dHomeVal) const ; diff --git a/MachineAxes.cpp b/MachineAxes.cpp index 013127a..dbd3316 100644 --- a/MachineAxes.cpp +++ b/MachineAxes.cpp @@ -22,6 +22,38 @@ using namespace std ; +//---------------------------------------------------------------------------- +bool +Machine::GetAxisToken( const string& sAxis, string& sToken) const +{ + // controllo GeomDB + if ( m_pGeomDB == nullptr) + return false ; + // recupero il relativo gestore + Axis* pAx = GetAxis( GetGroup( sAxis)) ; + if ( pAx == nullptr) + return false ; + // recupero il token dell'asse + sToken = pAx->GetToken() ; + return true ; +} + +//---------------------------------------------------------------------------- +bool +Machine::GetAxisType( const string& sAxis, bool& bLinear) const +{ + // controllo GeomDB + if ( m_pGeomDB == nullptr) + return false ; + // recupero il relativo gestore + Axis* pAx = GetAxis( GetGroup( sAxis)) ; + if ( pAx == nullptr) + return false ; + // recupero il tipo dell'asse + bLinear = ( pAx->GetType() == MCH_AT_LINEAR) ; + return true ; +} + //---------------------------------------------------------------------------- bool Machine::SetAxisPos( const string& sAxis, double dVal) diff --git a/OutputConst.h b/OutputConst.h index fd776f5..9927f3c 100644 --- a/OutputConst.h +++ b/OutputConst.h @@ -58,6 +58,7 @@ static const std::string GVAR_TCPOS = ".TCPOS" ; // (string) eventuale static const std::string GVAR_TCOMP = ".TCOMP" ; // (int) numero correttore utensile static const std::string GVAR_TDIAM = ".TDIAM" ; // (num) diametro utensile static const std::string GVAR_TLEN = ".TLEN" ; // (num) lunghezza utensile +static const std::string GVAR_SMAX = ".SMAX" ; // (num) massima speed utensile static const std::string GVAR_NEXTHEAD = ".NEXTHEAD" ; // (string) nome testa del prossimo utensile static const std::string GVAR_NEXTEXIT = ".NEXTEXIT" ; // (int) indice uscita su testa del prox utensile static const std::string GVAR_NEXTTCPOS = ".NEXTTCPOS" ; // (string) eventuale posizione del prox utensile nel TC diff --git a/Simulator.cpp b/Simulator.cpp index 0a954ec..c587ec0 100644 --- a/Simulator.cpp +++ b/Simulator.cpp @@ -40,6 +40,7 @@ Simulator::Simulator( void) m_dCoeff = 0 ; m_AxesName.reserve( 8) ; m_AxesToken.reserve( 8) ; + m_AxesLinear.reserve( 8) ; m_AxesVal.reserve( 8) ; } @@ -77,6 +78,7 @@ Simulator::Start( void) m_sTool.clear() ; m_AxesName.clear() ; m_AxesToken.clear() ; + m_AxesLinear.clear() ; // porto la macchina in home if ( ! GoHome()) return false ; @@ -386,22 +388,34 @@ Simulator::Move( int& nStatus) //---------------------------------------------------------------------------- bool -Simulator::GetAxisInfoPos( int nI, string& sToken, double& dVal) +Simulator::GetAxisInfoPos( int nI, string& sToken, bool& bLinear, double& dVal) const { // Verifiche if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) return false ; + // numero assi di calcolo e ausiliari + int nAxisCount = int( m_AxesName.size()) ; + int nAuxAxisCount = int( m_AuxAxesName.size()) ; // recupero i dati dell'asse - if ( nI < 0 || nI >= int( m_AxesName.size())) + if ( nI < 0 || nI >= nAxisCount + nAuxAxisCount) return false ; - string sName = m_AxesName[nI] ; - sToken = m_AxesToken[nI] ; + string sName ; + if ( nI < nAxisCount) { + sName = m_AxesName[nI] ; + sToken = m_AxesToken[nI] ; + bLinear = m_AxesLinear[nI] ; + } + else { + sName = m_AuxAxesName[ nI - nAxisCount] ; + sToken = m_AuxAxesToken[ nI - nAxisCount] ; + bLinear = m_AuxAxesLinear[ nI - nAxisCount] ; + } return m_pMchMgr->GetAxisPos( sName, dVal) ; } //---------------------------------------------------------------------------- bool -Simulator::GetToolInfo( string& sName, double& dSpeed) +Simulator::GetToolInfo( string& sName, double& dSpeed) const { // Verifiche if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) @@ -419,7 +433,7 @@ Simulator::GetToolInfo( string& sName, double& dSpeed) //---------------------------------------------------------------------------- bool -Simulator::GetMoveInfo( int& nGmove, double& dFeed) +Simulator::GetMoveInfo( int& nGmove, double& dFeed) const { // Verifiche if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr) @@ -566,9 +580,12 @@ Simulator::UpdateAxes( void) if ( ! pMachine->GetAllCurrAxesName( m_AxesName) || ! pMachine->GetAllCurrAxesToken( m_AxesToken)) return false ; - // Aggiorno la posizione corrente degli assi macchina attivi + // Aggiorno il tipo e la posizione corrente degli assi macchina attivi m_AxesVal.clear() ; for ( size_t i = 0 ; i < m_AxesName.size() ; ++ i) { + bool bLinear ; + m_pMachine->GetAxisType(m_AxesName[i], bLinear) ; + m_AxesLinear.push_back( bLinear) ; double dVal ; m_pMachine->GetAxisPos( m_AxesName[i], dVal) ; m_AxesVal.emplace_back( dVal) ; @@ -779,6 +796,8 @@ Simulator::OnMoveStart( const CamData* pCamData) { // pulisco dati assi ausiliari m_AuxAxesName.clear() ; + m_AuxAxesToken.clear() ; + m_AuxAxesLinear.clear() ; m_AuxAxesVal.clear() ; m_AuxAxesEnd.clear() ; @@ -820,16 +839,21 @@ Simulator::OnMoveStart( const CamData* pCamData) if ( ! m_pMachine->LuaGetGlobVar( GLOB_VAR + GVAR_AUXAXES, nNumAuxAxes) || nNumAuxAxes == 0) return true ; m_AuxAxesName.reserve( nNumAuxAxes) ; + m_AuxAxesToken.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 sName ; string sToken ; bool bLinear ; double dVal ; double dEnd ; string sAuxAxVal = GLOB_VAR + GVAR_AN ; ReplaceString( sAuxAxVal, "N", ToString( i)) ; string sAuxAxName = GLOB_VAR + GVAR_ANN ; ReplaceString( sAuxAxName, "N", ToString( i)) ; if ( m_pMachine->LuaGetGlobVar( sAuxAxName, sName) && - m_pMachine->GetAxisPos( sName, dVal) && - m_pMachine->LuaGetGlobVar( sAuxAxVal, dEnd)) { + m_pMachine->GetAxisToken( sName, sToken) && + m_pMachine->GetAxisType( sName, bLinear) && + m_pMachine->GetAxisPos( sName, dVal) && + m_pMachine->LuaGetGlobVar( sAuxAxVal, dEnd)) { m_AuxAxesName.emplace_back( sName) ; + m_AuxAxesToken.emplace_back( sToken) ; + m_AuxAxesLinear.push_back( bLinear) ; m_AuxAxesVal.emplace_back( dVal) ; m_AuxAxesEnd.emplace_back( dEnd) ; } diff --git a/Simulator.h b/Simulator.h index 9259ad6..ddd8e58 100644 --- a/Simulator.h +++ b/Simulator.h @@ -29,9 +29,9 @@ class Simulator bool Init( MachMgr* pMchMgr) ; bool Start( void) ; bool Move( int& nStatus) ; - bool GetAxisInfoPos( int nI, std::string& sToken, double& dVal) ; - bool GetToolInfo( std::string& sName, double& dSpeed) ; - bool GetMoveInfo( int& nGmove, double& dFeed) ; + bool GetAxisInfoPos( int nI, std::string& sToken, bool& bLinear, double& dVal) const ; + bool GetToolInfo( std::string& sName, double& dSpeed) const ; + bool GetMoveInfo( int& nGmove, double& dFeed) const ; bool SetStep( double dStep) ; bool GoHome( void) ; bool Stop( void) ; @@ -73,8 +73,11 @@ class Simulator std::string m_sTool ; // nome dell'utensile corrente STRVECTOR m_AxesName ; // nomi degli assi macchina attivi STRVECTOR m_AxesToken ; // token degli assi macchina attivi + BOOLVECTOR m_AxesLinear ; // flag di lineare 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 + STRVECTOR m_AuxAxesToken ; // token degli assi macchina ausiliari abilitati + BOOLVECTOR m_AuxAxesLinear ; // flag di lineare 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 } ;