EgtMachKernel 2.3l2 :

- in simulazione aggiunta gestione assi linkati ad altri assi.
This commit is contained in:
DarioS
2021-12-28 08:39:00 +01:00
parent 7ee1253b3c
commit 46d433296b
6 changed files with 99 additions and 26 deletions
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -855,7 +855,7 @@ MachMgr::TdbExport( const STRVECTOR& vsToolsNames, const string& sOutFile) const
if ( vsToolsNames.empty())
return true ;
// recupero il gestore di utensili della macchina corrente
// recupero il gestore di utensili della macchina corrente
ToolsMgr* pTsMgr = GetCurrToolsMgr() ;
if ( pTsMgr == nullptr)
return false ;
+1
View File
@@ -150,6 +150,7 @@ static const std::string GVAR_SHOWAXES = ".ShowAxes" ; // (bool) flag visu
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_ANN = ".ANn" ; // (string) nome del N-esimo asse ausiliario per simulazione
static const std::string GVAR_ANM = ".ANm" ; // (string) asse master del N-esimo asse ausiliario per simulazione
static const std::string GVAR_VMILL = ".VMILL" ; // (int/s) identificativi Zmap attivi per Virtual Milling
static const std::string GVAR_CODET = ".CODET" ; // (int/s) identificativi Zmap attivi per Collision Detection
static const std::string GVAR_SIM1ST = ".SIM1ST" ; // (bool) flag inizio simulazione
+92 -21
View File
@@ -604,6 +604,7 @@ Simulator::ResetAuxAxes( void)
m_AuxAxesLinear.clear() ;
m_AuxAxesVal.clear() ;
m_AuxAxesEnd.clear() ;
m_AuxAxesLink.clear() ;
// abilito assi principali
m_bEnabAxes = true ;
m_bShowAxes = true ;
@@ -1010,14 +1011,28 @@ Simulator::ManageSingleMove( int& nStatus, double& dMove)
}
for ( int i = 1 ; i <= nStep ; ++ i) {
double dCurrCoeff = dPrevCoeff + ( m_dCoeff - dPrevCoeff) / nStep * i ;
DBLVECTOR vDeltaVal( m_AxesName.size()) ;
// assegno posizioni finali
for ( int j = 0 ; j < int( m_AxesName.size()) ; ++ j) {
double dPrevVal ;
m_pMachine->GetAxisPos( m_AxesName[j], dPrevVal) ;
double dVal = m_AxesVal[j] * ( 1 - dCurrCoeff) + AxesEnd[j] * dCurrCoeff ;
m_pMachine->SetAxisPos( m_AxesName[j], dVal) ;
vDeltaVal[j] = dVal - dPrevVal ;
}
// muovo eventuali assi ausiliari
for ( int j = 0 ; j < int( m_AuxAxesName.size()) ; ++ j) {
double dVal = m_AuxAxesVal[j] * ( 1 - dCurrCoeff) + m_AuxAxesEnd[j] * dCurrCoeff ;
double dVal = 0 ;
if ( m_AuxAxesLink[j] == 0) {
dVal = m_AuxAxesVal[j] * ( 1 - dCurrCoeff) + m_AuxAxesEnd[j] * dCurrCoeff ;
}
else {
m_pMachine->GetAxisPos( m_AuxAxesName[j], dVal) ;
if ( m_AuxAxesLink[j] > 0)
dVal += vDeltaVal[m_AuxAxesLink[j] - 1] ;
else
dVal -= vDeltaVal[-m_AuxAxesLink[j] - 1] ;
}
m_pMachine->SetAxisPos( m_AuxAxesName[j], dVal) ;
}
// eseguo eventuale collision check
@@ -1058,19 +1073,42 @@ Simulator::ManageSingleMove( int& nStatus, double& dMove)
}
for ( int i = 1 ; i <= nStep ; ++ i) {
double dCurrCoeff = dPrevCoeff + ( m_dCoeff - dPrevCoeff) / nStep * i ;
DBLVECTOR vDeltaVal( m_AxesName.size()) ;
// assi lineari
vtRot.Rotate( vtN, dDiffAng / nStep) ;
m_pMachine->SetAxisPos( m_AxesName[0], ptCen.x + vtRot.x + dCurrCoeff * dDeltaN * vtN.x) ;
m_pMachine->SetAxisPos( m_AxesName[1], ptCen.y + vtRot.y + dCurrCoeff * dDeltaN * vtN.y) ;
m_pMachine->SetAxisPos( m_AxesName[2], ptCen.z + vtRot.z + dCurrCoeff * dDeltaN * vtN.z) ;
double dPrevVal, dVal ;
m_pMachine->GetAxisPos( m_AxesName[0], dPrevVal) ;
dVal = ptCen.x + vtRot.x + dCurrCoeff * dDeltaN * vtN.x ;
m_pMachine->SetAxisPos( m_AxesName[0], dVal) ;
vDeltaVal[0] = dVal - dPrevVal ;
m_pMachine->GetAxisPos( m_AxesName[1], dPrevVal) ;
dVal = ptCen.y + vtRot.y + dCurrCoeff * dDeltaN * vtN.y ;
m_pMachine->SetAxisPos( m_AxesName[1], dVal) ;
vDeltaVal[1] = dVal - dPrevVal ;
m_pMachine->GetAxisPos( m_AxesName[2], dPrevVal) ;
dVal = ptCen.z + vtRot.z + dCurrCoeff * dDeltaN * vtN.z ;
m_pMachine->SetAxisPos( m_AxesName[2], dVal) ;
vDeltaVal[2] = dVal - dPrevVal ;
// assi rotanti
for ( int j = 3 ; j < int( m_AxesName.size()) ; ++ j) {
double dPrevVal ; m_pMachine->GetAxisPos( m_AxesName[j], dPrevVal) ;
double dVal = m_AxesVal[j] * ( 1 - dCurrCoeff) + AxesEnd[j] * dCurrCoeff ;
m_pMachine->SetAxisPos( m_AxesName[j], dVal) ;
vDeltaVal[j] = dVal - dPrevVal ;
}
// eventuali assi ausiliari
for ( int j = 0 ; j < int( m_AuxAxesName.size()) ; ++ j) {
double dVal = m_AuxAxesVal[j] * ( 1 - dCurrCoeff) + m_AuxAxesEnd[j] * dCurrCoeff ;
double dVal = 0 ;
if ( m_AuxAxesLink[j] == 0) {
dVal = m_AuxAxesVal[j] * ( 1 - dCurrCoeff) + m_AuxAxesEnd[j] * dCurrCoeff ;
}
else {
m_pMachine->GetAxisPos( m_AuxAxesName[j], dVal) ;
if ( m_AuxAxesLink[j] > 0)
dVal += vDeltaVal[m_AuxAxesLink[j] - 1] ;
else
dVal -= vDeltaVal[-m_AuxAxesLink[j] - 1] ;
}
m_pMachine->SetAxisPos( m_AuxAxesName[j], dVal) ;
}
// eseguo eventuale Vmill
@@ -1123,8 +1161,13 @@ Simulator::ManageSingleMove( int& nStatus, double& dMove)
double dCurrCoeff = dPrevCoeff + ( m_dCoeff - dPrevCoeff) / nStep * i ;
// muovo eventuali assi ausiliari
for ( int j = 0 ; j < int( m_AuxAxesName.size()) ; ++ j) {
double dVal = m_AuxAxesVal[j] * ( 1 - dCurrCoeff) + m_AuxAxesEnd[j] * dCurrCoeff ;
m_pMachine->SetAxisPos( m_AuxAxesName[j], dVal) ;
if ( m_AuxAxesLink[j] == 0) {
double dVal = m_AuxAxesVal[j] * ( 1 - dCurrCoeff) + m_AuxAxesEnd[j] * dCurrCoeff ;
m_pMachine->SetAxisPos( m_AuxAxesName[j], dVal) ;
}
else {
}
}
// eseguo eventuale collision check
bCollCheck = bCollCheck && ExecCollisionCheck( nCdInd, nObjInd, nMoveType) ;
@@ -1487,6 +1530,7 @@ Simulator::OnToolSelect( const string& sTool, const string& sHead, int nExit, co
m_AuxAxesLinear.push_back( bLinear) ;
m_AuxAxesVal.emplace_back( dVal) ;
m_AuxAxesEnd.emplace_back( dVal) ;
m_AuxAxesLink.emplace_back( 0) ;
}
}
else
@@ -1734,28 +1778,55 @@ Simulator::OnMoveStart( const CamData* pCamData, int& nErr)
m_AuxAxesVal.reserve( nNumAuxAxes) ;
m_AuxAxesEnd.reserve( nNumAuxAxes) ;
for ( int i = 1 ; i <= nNumAuxAxes && bOk ; ++ i) {
string sName ; string sToken ; bool bInvert ; bool bLinear ; double dVal ; double dEnd ;
string sName ; string sToken ; bool bInvert ; bool bLinear ; double dVal ; double dEnd ; string sLink ;
string sAuxAxVal = GLOB_VAR + GVAR_AN ; ReplaceString( sAuxAxVal, "N", ToString( i)) ;
string sAuxAxName = GLOB_VAR + GVAR_ANN ; ReplaceString( sAuxAxName, "N", ToString( i)) ;
string sAuxAxMaster = GLOB_VAR + GVAR_ANM ; ReplaceString( sAuxAxMaster, "N", ToString( i)) ;
if ( m_pMachine->LuaGetGlobVar( sAuxAxName, sName) &&
m_pMachine->GetAxisToken( sName, sToken) &&
m_pMachine->GetAxisInvert( sName, bInvert) &&
m_pMachine->GetAxisType( sName, bLinear) &&
m_pMachine->GetAxisPos( sName, dVal) &&
m_pMachine->LuaGetGlobVar( sAuxAxVal, dEnd)) {
// se assi principali disabilitati o non è tra questi, lo aggiungo
if ( ! m_bEnabAxes || find( m_AxesName.begin(), m_AxesName.end(), sName) == m_AxesName.end()) {
m_AuxAxesName.emplace_back( sName) ;
m_AuxAxesToken.emplace_back( sToken) ;
m_AuxAxesInvert.push_back( bInvert) ;
m_AuxAxesLinear.push_back( bLinear) ;
m_AuxAxesVal.emplace_back( dVal) ;
m_AuxAxesEnd.emplace_back( dEnd) ;
if ( ! m_pMachine->VerifyOutstroke( sName, dEnd)) {
nErr = 1 ;
bOk = false ;
m_pMachine->GetAxisPos( sName, dVal)) {
// se da agganciare ad asse principale
if ( m_pMachine->LuaGetGlobVar( sAuxAxMaster, sLink)) {
bool bNeg = ( sLink.find( '-') != string::npos) ;
string sMainAxis = sLink ; ReplaceString( sMainAxis, "-", "") ;
int nInd = 0 ;
for ( int i = 0 ; nInd == 0 && i < int( m_AxesName.size()) ; ++ i) {
if ( m_AxesName[i] == sMainAxis)
nInd = i + 1 ;
}
// se assi principali abilitati e trovato asse principale di riferimento
if ( m_bEnabAxes && nInd > 0) {
m_AuxAxesName.emplace_back( sName) ;
m_AuxAxesToken.emplace_back( sToken) ;
m_AuxAxesInvert.push_back( bInvert) ;
m_AuxAxesLinear.push_back( bLinear) ;
m_AuxAxesVal.emplace_back( 0) ;
m_AuxAxesEnd.emplace_back( 0) ;
m_AuxAxesLink.emplace_back( ( bNeg ? -nInd : nInd)) ;
}
}
// se altrimenti specificato valore finale del movimento
else if ( m_pMachine->LuaGetGlobVar( sAuxAxVal, dEnd)) {
// se assi principali disabilitati o non è tra questi, lo aggiungo
if ( ! m_bEnabAxes || find( m_AxesName.begin(), m_AxesName.end(), sName) == m_AxesName.end()) {
m_AuxAxesName.emplace_back( sName) ;
m_AuxAxesToken.emplace_back( sToken) ;
m_AuxAxesInvert.push_back( bInvert) ;
m_AuxAxesLinear.push_back( bLinear) ;
m_AuxAxesVal.emplace_back( dVal) ;
m_AuxAxesEnd.emplace_back( dEnd) ;
m_AuxAxesLink.emplace_back( 0) ;
if ( ! m_pMachine->VerifyOutstroke( sName, dEnd)) {
nErr = 1 ;
bOk = false ;
}
}
}
// altrimenti errore
else
bOk = false ;
}
else
bOk = false ;
+1
View File
@@ -145,4 +145,5 @@ class Simulator
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
INTVECTOR m_AuxAxesLink ; // indice + 1 asse principale di aggancio (negativo valore opposto, 0 nessuno)
} ;
+4 -4
View File
@@ -857,7 +857,7 @@ bool
ToolsMgr::ExportOneTool( const string& sToolName, Writer& TheWriter, int nCounter, const string& sOutDir) const
{
// se il tool non esiste nel DB lo ignoro
if ( m_suData.find( sToolName) == m_suData.end()){
if ( m_suData.find( sToolName) == m_suData.end()) {
string sOut = "Warning Export Tool : " + sToolName + " not found. Tool is ignored" ;
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
return true ;
@@ -865,7 +865,7 @@ ToolsMgr::ExportOneTool( const string& sToolName, Writer& TheWriter, int nCounte
const ToolData * tData = GetTool( sToolName) ;
string sOut ;
if ( tData == nullptr){
if ( tData == nullptr) {
sOut = "Export Tools : Error exporting " + sToolName ;
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
return false ;
@@ -885,7 +885,7 @@ ToolsMgr::ExportOneTool( const string& sToolName, Writer& TheWriter, int nCounte
bOk = ! sOut.empty() && TheWriter.OutText( sOut) ;
}
if ( ! bOk){
if ( ! bOk) {
sOut = "Export Tools : Error exporting " + sToolName ;
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
// visto che non ho salvato correttamente il tool elimino il suo disegno
@@ -1155,7 +1155,7 @@ ToolsMgr::CopyToolDraw( const string& sDraw, const string& sOutDraw, const strin
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
bOk = false ;
}
if ( bOk && ! ExeTdbCurrToolDraw( nGenCtx, nToolCtx)) {
if ( bOk && ExeTdbCurrToolDraw( nGenCtx, nToolCtx) != 0) {
string sOut = " Error : " + sToolName + " CurrToolDraw" ;
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
bOk = false ;