diff --git a/Disposition.cpp b/Disposition.cpp index 8420965..06c1dc0 100644 --- a/Disposition.cpp +++ b/Disposition.cpp @@ -1076,11 +1076,12 @@ Disposition::SpecialApply( bool bRecalc) // segnalo errori if ( nErr != 0) { bOk = false ; + m_nShifts = - 1 ; string sOut = " Error in " + ON_SPECIAL_APPLY + " (" + ToString( nErr) + ")" ; LOG_INFO( GetEMkLogger(), sOut.c_str()) } // se disposizione vuota, esco - if ( m_nShifts == 0) + if ( m_nShifts <= 0) return bOk ; // calcolo assi macchina string sHint = "" ; @@ -1097,7 +1098,7 @@ Disposition::SpecialApply( bool bRecalc) bool Disposition::GetToolData( string& sName, string& sHead, int& nExit, string& sTcPos) const { - sName = "" ; + sName = "*" + m_sHead ; sHead = m_sHead ; nExit = m_nExit ; sTcPos = m_sTcPos ; diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index c164383..ea71105 100644 Binary files a/EgtMachKernel.rc and b/EgtMachKernel.rc differ diff --git a/Generator.cpp b/Generator.cpp index d86252e..b5dc8d7 100644 --- a/Generator.cpp +++ b/Generator.cpp @@ -438,7 +438,7 @@ Generator::UpdateTool( const string& sTool) { // Salvo l'utensile attuale come precedente m_sPrevTool = m_sTool ; - // Se cambiato ... + // Se cambiato utensile ... if ( sTool != m_sTool) { // lo imposto come corrente if ( ! m_pMchMgr->TdbSetCurrTool( sTool)) @@ -758,7 +758,8 @@ bool Generator::OnToolSelect( const string& sTool, const string& sHead, int nExit, const string& sTcPos) { // assegno il nome dell'utensile, la testa, l'uscita e l'eventuale posizione nel toolchanger - bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TOOL, sTool) ; + string sOutTool = ( ( sTool.empty() || sTool.front() == '*') ? "" : sTool) ; + bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TOOL, sOutTool) ; bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_HEAD, sHead) ; bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_EXIT, nExit) ; bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TCPOS, sTcPos) ; diff --git a/MachMgr.h b/MachMgr.h index 4ff70ab..b2d6546 100644 --- a/MachMgr.h +++ b/MachMgr.h @@ -261,6 +261,7 @@ class MachMgr : public IMachMgr bool SetCalcTable( const std::string& sTable) override ; bool SetCalcTool( const std::string& sTool, const std::string& sHead, int nExit) override ; bool SetRotAxisBlock( const std::string& sAxis, double dVal) override ; + bool GetRotAxisBlocked( int nInd, std::string& sAxis, double& dVal) override ; bool GetCalcTool( std::string& sTool) const override ; bool GetCalcAngles( const Vector3d& vtDirT, const Vector3d& vtDirA, int& nStat, double& dAngA1, double& dAngB1, double& dAngA2, double& dAngB2) const override ; diff --git a/MachMgrMachines.cpp b/MachMgrMachines.cpp index ea6079d..55840f5 100644 --- a/MachMgrMachines.cpp +++ b/MachMgrMachines.cpp @@ -333,6 +333,34 @@ MachMgr::SetRotAxisBlock( const string& sAxis, double dVal) return true ; } +//---------------------------------------------------------------------------- +bool +MachMgr::GetRotAxisBlocked( int nInd, string& sAxis, double& dVal) +{ + // se bloccaggi non ancora impostati + if ( ! m_vAxisBlock.empty()) { + if ( nInd < 0 || nInd >= int( m_vAxisBlock.size())) + return false ; + sAxis = m_vAxisBlock[nInd].sAxis ; + dVal = m_vAxisBlock[nInd].dVal ; + return true ; + } + // altrimenti cerco negli assi rotanti correnti + Machine* pMch = GetCurrMachine() ; + if ( pMch == nullptr) + return false ; + int nMyInd = 0 ; + for ( int i = 0 ; i < pMch->GetCurrRotAxes() ; ++ i) { + if ( pMch->GetKinematicRotAxisBlocked( i, sAxis, dVal)) { + if ( nMyInd == nInd) + return true ; + else + ++ nMyInd ; + } + } + return false ; +} + //---------------------------------------------------------------------------- bool MachMgr::ApplyRotAxisBlock( void) diff --git a/Machine.h b/Machine.h index 331ed8e..652f718 100644 --- a/Machine.h +++ b/Machine.h @@ -85,6 +85,7 @@ class Machine bool FreeKinematicRotAxis( const std::string& sName) ; bool FreeKinematicRotAxis( int nId) ; bool IsKinematicRotAxisBlocked( int nInd) const ; + bool GetKinematicRotAxisBlocked( int nInd, std::string& sName, double& dVal) const ; bool SetSolCh( int nScc) ; int GetCurrLinAxes( void) const ; int GetCurrRotAxes( void) const ; diff --git a/MachineCalc.cpp b/MachineCalc.cpp index a64af6a..a3a6a11 100644 --- a/MachineCalc.cpp +++ b/MachineCalc.cpp @@ -210,9 +210,12 @@ Machine::SetCurrTool( const string& sTool, const string& sHead, int nExit) double dTOvLen = 0 ; double dTOvDiam = 0 ; // se definito - if ( ! sTool.empty()) { - if ( ! LoadTool( sHead, nExit, sTool)) + if ( ! sTool.empty() && sTool.front() != '*') { + if ( ! LoadTool( sHead, nExit, sTool)) { + string sOut = "Missing tool " + sTool ; + LOG_INFO( GetEMkLogger(), sOut.c_str()) return false ; + } nToolId = m_pGeomDB->GetFirstNameInGroup( nExitId, sTool) ; if ( nToolId == GDB_ID_NULL || m_pGeomDB->GetGdbType( nToolId) != GDB_TY_GROUP) return false ; @@ -233,7 +236,7 @@ Machine::SetCurrTool( const string& sTool, const string& sHead, int nExit) dTDiam = 0 ; dTOvLen = 0 ; dTOvDiam = 0 ; - m_pMchMgr->TdbSetCurrTool( sTool) ; + m_pMchMgr->TdbSetCurrTool( "") ; } // assegno tutti i dati m_nCalcHeadId = nHeadId ; @@ -531,6 +534,18 @@ Machine::IsKinematicRotAxisBlocked( int nInd) const return m_vCalcRotAx[nInd].bFixed ; } +//---------------------------------------------------------------------------- +bool +Machine::GetKinematicRotAxisBlocked( int nInd, string& sName, double& dVal) const +{ + int nRotAxTot = int( m_vCalcRotAx.size()) ; + if ( nInd < 0 || nInd >= nRotAxTot || ! m_vCalcRotAx[nInd].bFixed) + return false ; + m_pGeomDB->GetName( m_vCalcRotAx[nInd].nGrpId, sName) ; + dVal = m_vCalcRotAx[nInd].dFixVal ; + return true ; +} + //---------------------------------------------------------------------------- bool Machine::SetSolCh( int nScc) diff --git a/ToolsMgr.cpp b/ToolsMgr.cpp index 4c788ba..fc7e3ff 100644 --- a/ToolsMgr.cpp +++ b/ToolsMgr.cpp @@ -333,6 +333,9 @@ ToolsMgr::GetToolNewName( string& sName) const bool ToolsMgr::AddTool( const string& sName, int nType) { + // verifico validità del nome + if ( ! IsValidName( sName)) + return false ; // verifico unicità del nome if ( m_suData.find( sName) != m_suData.end()) return false ; @@ -359,6 +362,9 @@ ToolsMgr::AddTool( const string& sName, int nType) bool ToolsMgr::CopyTool( const string& sSource, const string& sName) { + // verifico validità del nome + if ( ! IsValidName( sName)) + return false ; // verifico unicità del nome if ( m_suData.find( sName) != m_suData.end()) return false ; @@ -568,8 +574,10 @@ ToolsMgr::SetCurrToolParam( int nType, const string& sVal) // non è possibile cambiare UUID if ( nType == TPA_UUID) return false ; - // è possibile cambiare il nome, solo se il nuovo non è già presente nel DB (escluso utensile corrente) + // è possibile cambiare il nome, solo se il nuovo è valido e non è già presente nel DB (escluso utensile corrente) if ( nType == TPA_NAME) { + if ( ! IsValidName( sVal)) + return false ; const ToolData* pTdata = GetTool( sVal) ; if ( pTdata != nullptr && pTdata->m_Uuid != m_tdCurrTool.m_Uuid) return false ;