EgtMachKernel :

- velocizzata GetEMkVer che rallentava assegnazione della variabile lua con versione della dll (specie in verifica aree protette)
- migliorata verifica extracorse in calcolo assi centri di lavoro.
This commit is contained in:
Dario Sassi
2025-09-30 08:25:27 +02:00
parent 34a26f7d3e
commit 75fa4a3f90
5 changed files with 61 additions and 53 deletions
+1 -1
View File
@@ -18,7 +18,7 @@
#include <string>
//-----------------------------------------------------------------------------
std::string GetEMkVer( void) ;
const std::string& GetEMkVer( void) ;
ILogger* GetEMkLogger( void) ;
const std::string& GetEMkKey( void) ;
bool GetEMkNetHwKey( void) ;
+12 -10
View File
@@ -31,8 +31,7 @@
const int STR_DIM = 40 ;
//-----------------------------------------------------------------------------
static HINSTANCE s_hModule = NULL ;
static char s_szEMkNameVer[STR_DIM] ;
static HINSTANCE s_hModule = NULL ;
//-----------------------------------------------------------------------------
extern "C" int APIENTRY
@@ -62,21 +61,24 @@ DllMain( HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
const char*
GetEMkVersion( void)
{
std::string sVer ;
GetModuleVersion( s_hModule, sVer) ;
sprintf_s( s_szEMkNameVer, STR_DIM, "%s%s", EMK_STR, sVer.c_str()) ;
static char s_szEMkNameVer[STR_DIM] = "" ;
if ( s_szEMkNameVer[0] == '\0') {
static std::string sVer ;
GetModuleVersion( s_hModule, sVer) ;
sprintf_s( s_szEMkNameVer, STR_DIM, "%s%s", EMK_STR, sVer.c_str()) ;
}
return s_szEMkNameVer ;
}
//-----------------------------------------------------------------------------
std::string
const std::string&
GetEMkVer( void)
{
std::string sVer ;
GetModuleVersion( s_hModule, sVer) ;
return sVer ;
static std::string s_sVer ;
if ( s_sVer.empty())
GetModuleVersion( s_hModule, s_sVer) ;
return s_sVer ;
}
//-----------------------------------------------------------------------------
+18 -12
View File
@@ -1952,14 +1952,14 @@ Operation::CalculateClPathMcentAxesValues( int nClPathId, double dAngDeltaMinFor
EraseAddedPoints( nClPathId) ;
// calcolo
int nOutStrC = 0 ;
if ( ! MyCalculateClPathMcentAxesValues( nClPathId, dAngDeltaMinForHome, vAxRotHome, vAxRotPrec, nOutStrC)) {
if ( ! MyCalculateClPathMcentAxesValues( nClPathId, dAngDeltaMinForHome, vAxRotHome, vAxRotPrec, true, nOutStrC)) {
// se attivata scelta angolo iniziale vicino ad home ed extra corsa C, provo a rifarlo disattivando
if ( dAngDeltaMinForHome < ANG_FULL && nOutStrC != 0) {
// cancello eventuali punti aggiunti
EraseAddedPoints( nClPathId) ;
// ricalcolo
m_pMchMgr->GetCurrMachine()->ResetOutstrokeInfo() ;
if ( MyCalculateClPathMcentAxesValues( nClPathId, INFINITO, vAxRotHome, vAxRotPrec, nOutStrC))
if ( MyCalculateClPathMcentAxesValues( nClPathId, INFINITO, vAxRotHome, vAxRotPrec, false, nOutStrC))
return true ;
}
// se extracorsa dell'asse C, provo a precaricarlo al contrario
@@ -1970,7 +1970,7 @@ Operation::CalculateClPathMcentAxesValues( int nClPathId, double dAngDeltaMinFor
vAxRotPrec = vAxRotPrecOri ;
vAxRotPrec[0] = vAxRotPrecOri[0] + ( nOutStrC > 0 ? - ANG_FULL : ANG_FULL) ;
m_pMchMgr->GetCurrMachine()->ResetOutstrokeInfo() ;
if ( ! MyCalculateClPathMcentAxesValues( nClPathId, INFINITO, vAxRotHome, vAxRotPrec, nOutStrC))
if ( ! MyCalculateClPathMcentAxesValues( nClPathId, INFINITO, vAxRotHome, vAxRotPrec, false, nOutStrC))
return false ;
}
else
@@ -2000,7 +2000,7 @@ Operation::EraseAddedPoints( int nClPathId)
//----------------------------------------------------------------------------
bool
Operation::MyCalculateClPathMcentAxesValues( int nClPathId, double dAngDeltaMinForHome, const DBLVECTOR& vAxRotHome,
DBLVECTOR& vAxRotPrec, int& nOutStrC)
DBLVECTOR& vAxRotPrec, bool bFirstTry, int& nOutStrC)
{
if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr)
return false ;
@@ -2078,6 +2078,9 @@ Operation::MyCalculateClPathMcentAxesValues( int nClPathId, double dAngDeltaMinF
}
string sInfo = "Outstroke : " + m_pMchMgr->GetOutstrokeInfo() ;
LOG_INFO( GetEMkLogger(), sInfo.c_str())
// se primo calcolo ed extra corsa asse C esco, altrimenti continuo
if ( bFirstTry && nOutStrC != 0)
return bOk ;
// calcolo e salvo il valore dell'asse ausiliario di testa riportato sul grezzo
Vector3d vtBackAux ;
pMachine->GetBackAuxDirFromAngles( vAxRot, vtBackAux) ;
@@ -2124,20 +2127,23 @@ Operation::MyCalculateClPathMcentAxesValues( int nClPathId, double dAngDeltaMinF
bOk = false ;
}
// Se esistono aree protette, devo comunque verificare i punti intermedi
if ( ! bMidAdded && m_pMchMgr->ExistProtectedAreas()) {
if ( ! bMidAdded && pMachine->ExistProtectedAreas()) {
// verifico i limiti di corsa dei punti lungo la linea
const int NUM_VERIF_STEP = 16 ;
Point3d ptPrec( vAxPrec[0], vAxPrec[1], vAxPrec[2]) ;
Point3d ptP( dX, dY, dZ) ;
for ( int i = 1 ; i < NUM_VERIF_STEP ; ++ i) {
double dCoeff = double( i) / NUM_VERIF_STEP ;
double dLenMove = ApproxDist( ptPrec, ptP) ;
constexpr double PA_VERIF_LEN = 10 ;
constexpr int MAX_VERIF_STEP = 16 ;
const int nNumStep = max( min( int( dLenMove / PA_VERIF_LEN), MAX_VERIF_STEP), 1) ;
for ( int i = 1 ; i < nNumStep ; ++ i) {
double dCoeff = double( i) / nNumStep ;
Point3d ptCurr = Media( ptPrec, ptP, dCoeff) ;
DBLVECTOR vAng( vAxRot.size()) ;
for ( size_t i = 0 ; i < vAxRot.size() ; ++ i)
for ( int i = 0 ; i < int( vAxRot.size()) ; ++ i)
vAng[i] = vAxRotPrec[i] * ( 1 - dCoeff) + vAxRot[i] * dCoeff ;
int nStat ;
bool bOsOk = m_pMchMgr->VerifyOutstroke( ptCurr.x, ptCurr.y, ptCurr.z, vAng, false, nStat) ;
if ( ! bOsOk || nStat != 0) {
int nStat = 0 ;
bool bPaOk = pMachine->VerifyProtectedAreas( ptCurr.x, ptCurr.y, ptCurr.z, vAng, nStat) ;
if ( ! bPaOk || nStat != 0) {
bOk = false ;
pCamData->SetAxes( CamData::AS_OUTSTROKE, vAxVal) ;
string sInfo = "Outstroke : " + m_pMchMgr->GetOutstrokeInfo() ;
+1 -1
View File
@@ -215,7 +215,7 @@ class Operation : public IUserObj
DBLVECTOR& vAxRotPrec) ;
bool EraseAddedPoints( int nClPathId) ;
bool MyCalculateClPathMcentAxesValues( int nClPathId, double dAngDeltaMinForHome, const DBLVECTOR& vAxRotHome,
DBLVECTOR& vAxRotPrec, int& nOutStrC) ;
DBLVECTOR& vAxRotPrec, bool bFirstTry, int& nOutStrC) ;
bool CalculateMcentRotAxesValues( bool bFirst, const Vector3d& vtTool, const Vector3d& vtAux,
double dAngDeltaMinForHome, const DBLVECTOR& vAxRotHome, const DBLVECTOR& vAxRotPrec,
DBLVECTOR& vAxRot) ;
+29 -29
View File
@@ -4,7 +4,7 @@
// File : SawFinishing.cpp Data : 23.04.19 Versione : 2.1d3
// Contenuto : Implementazione gestione finitura superficie con lama.
//
// Note : Questa lavorazione è sempre espressa nel riferimento globale.
// Note : Questa lavorazione è sempre espressa nel riferimento globale.
//
// Modifiche : 05.04.16 DS Creazione modulo.
// 23.04.19 DS Aggiunte cornici curve.
@@ -446,15 +446,15 @@ SawFinishing::SetParam( int nType, const string& sVal)
bool
SawFinishing::SetGeometry( const SELVECTOR& vIds)
{
// verifico validità gestore DB geometrico
// verifico validità gestore DB geometrico
if ( m_pGeomDB == nullptr)
return false ;
// copia temporanea e reset della geometria corrente
SELVECTOR vOldId = m_vId ;
m_vId.clear() ;
// verifico che gli identificativi rappresentino delle entità ammissibili
// verifico che gli identificativi rappresentino delle entità ammissibili
for ( const auto& Id : vIds) {
// test sull'entità
// test sull'entità
int nSubs ;
if ( ! VerifyGeometry( Id, nSubs)) {
string sInfo = "Warning in SawFinishing : Skipped entity " + ToString( Id) ;
@@ -487,7 +487,7 @@ SawFinishing::Apply( bool bRecalc, bool bPostApply)
int nCurrCuts = m_nCuts ;
m_nCuts = 0 ;
// verifico validità gestore DB geometrico e Id del gruppo
// verifico validità gestore DB geometrico e Id del gruppo
if ( m_pGeomDB == nullptr || ! m_pGeomDB->ExistsObj( m_nOwnerId))
return false ;
@@ -521,7 +521,7 @@ SawFinishing::Apply( bool bRecalc, bool bPostApply)
// recupero gruppo per geometria ausiliaria
int nAuxId = m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, MCH_AUX) ;
// se non c'è, lo aggiungo
// se non c'è, lo aggiungo
if ( nAuxId == GDB_ID_NULL) {
nAuxId = m_pGeomDB->AddGroup( GDB_ID_NULL, m_nOwnerId, Frame3d()) ;
if ( nAuxId == GDB_ID_NULL)
@@ -543,7 +543,7 @@ SawFinishing::Apply( bool bRecalc, bool bPostApply)
// recupero gruppo per geometria di lavorazione (Cutter Location)
int nClId = m_pGeomDB->GetFirstNameInGroup( m_nOwnerId, MCH_CL) ;
// se non c'è, lo aggiungo
// se non c'è, lo aggiungo
if ( nClId == GDB_ID_NULL) {
nClId = m_pGeomDB->AddGroup( GDB_ID_NULL, m_nOwnerId, Frame3d()) ;
if ( nClId == GDB_ID_NULL)
@@ -590,7 +590,7 @@ SawFinishing::Apply( bool bRecalc, bool bPostApply)
// eseguo aggiornamento assi macchina e collegamento con operazione precedente
if ( ! Update( bPostApply))
return false ;
// aggiorno stato della lavorazione
m_nStatus = ( bPostApply ? MCH_ST_OK : MCH_ST_NO_POSTAPPL) ;
// dichiaro successiva da aggiornare
@@ -605,7 +605,7 @@ SawFinishing::Apply( bool bRecalc, bool bPostApply)
bool
SawFinishing::Update( bool bPostApply)
{
// verifico validità gestore DB geometrico e Id del gruppo
// verifico validità gestore DB geometrico e Id del gruppo
if ( m_pGeomDB == nullptr || ! m_pGeomDB->ExistsObj( m_nOwnerId))
return false ;
@@ -615,7 +615,7 @@ SawFinishing::Update( bool bPostApply)
return true ;
}
// elimino le entità CLIMB, RISE e HOME della lavorazione, potrebbero falsare i calcoli degli assi (in ogni casi vengono riaggiunte dopo)
// elimino le entità CLIMB, RISE e HOME della lavorazione, potrebbero falsare i calcoli degli assi (in ogni casi vengono riaggiunte dopo)
RemoveClimbRiseHome() ;
// imposto eventuale asse bloccato da lavorazione
@@ -857,7 +857,7 @@ SawFinishing::UpdateToolData( bool* pbChanged)
bool
SawFinishing::GetGeometry( SELVECTOR& vIds) const
{
// restituisco l'elenco delle entità
// restituisco l'elenco delle entità
vIds = m_vId ;
return true ;
}
@@ -952,7 +952,7 @@ SawFinishing::GetCurve( SelData Id)
bool
SawFinishing::AdjustGeometry( int nAuxId)
{
// sgrossatura di cornici diritte : due o più curve (sezioni e guida rettilinea)
// sgrossatura di cornici diritte : due o più curve (sezioni e guida rettilinea)
// sgrossatura di cornici curve : due curve (sezione e guida curva)
size_t nCrvCount = m_vId.size() ;
if ( nCrvCount >= 2) {
@@ -976,7 +976,7 @@ SawFinishing::AdjustGeometry( int nAuxId)
return false ;
}
}
// l'ultima curva è la guida
// l'ultima curva è la guida
PtrOwner<ICurve> pGuide( GetCurve( m_vId[nCrvCount-1])) ;
if ( IsNull( pGuide))
return false ;
@@ -1190,7 +1190,7 @@ SawFinishing::CalculateStraightAlongToolPath( int nAuxId, int nClId)
}
}
}
// se c'è qualcosa in sospeso
// se c'è qualcosa in sospeso
if ( nStatus != CCL_VERT) {
bSkipMax = false ;
bool bInvert = ( nStatus == CCL_RISE) ;
@@ -1383,7 +1383,7 @@ SawFinishing::CalculateCurvedAlongToolPath( int nAuxId, int nClId)
// recupero il suo riferimento
Frame3d frGdL ;
m_pGeomDB->GetGlobFrame( nGuideId, frGdL) ;
// porto la curva in globale (dovrebbe già avere riferimento globale)
// porto la curva in globale (dovrebbe già avere riferimento globale)
pGuide->ToGlob( frGdL) ;
// recupero il box globale della linea guida
BBox3d b3Guide ;
@@ -1498,7 +1498,7 @@ SawFinishing::CalculateCurvedAlongToolPath( int nAuxId, int nClId)
}
}
}
// se c'è qualcosa in sospeso
// se c'è qualcosa in sospeso
if ( nStatus != CCL_VERT) {
bSkipMax = false ;
bool bInvert = ( nStatus == CCL_RISE) ;
@@ -1542,7 +1542,7 @@ SawFinishing::CalculateCurvedAcrossToolPath( int nAuxId, int nClId)
// recupero il suo riferimento
Frame3d frGdL ;
m_pGeomDB->GetGlobFrame( nGuideId, frGdL) ;
// porto la curva in globale (dovrebbe già avere riferimento globale)
// porto la curva in globale (dovrebbe già avere riferimento globale)
pGuide->ToGlob( frGdL) ;
// recupero il box globale della linea guida
BBox3d b3Guide ;
@@ -1645,7 +1645,7 @@ SawFinishing::CalculateCurvedAcrossToolPath( int nAuxId, int nClId)
vtCorr.Rotate( Z_AX, dAngRotDeg - 90) ;
// flag di inizio
bool bFirst = ( dLen < EPS_SMALL) ;
// se non è inizio
// se non è inizio
bool bCorner = false ;
Vector3d vtPrev ;
if ( ! bFirst) {
@@ -1786,7 +1786,7 @@ SawFinishing::CalculateSection( int nSectGrpId, ICurve*& pSect)
bool
SawFinishing::TrimSection( ICurve* pCrv)
{
// se parametri di accorciamento iniziale e finale sono nulli, non faccio alcunché
// se parametri di accorciamento iniziale e finale sono nulli, non faccio alcunché
if ( m_Params.m_dStartAddLen > - EPS_SMALL && m_Params.m_dEndAddLen > -EPS_SMALL)
return true ;
@@ -1839,7 +1839,7 @@ SawFinishing::CalculateGuideLine( int nGuideId, const BBox3d& b3Sect,
// recupero il suo riferimento
Frame3d frGdL ;
m_pGeomDB->GetGlobFrame( nGuideId, frGdL) ;
// porto la curva in globale (dovrebbe già avere riferimento globale)
// porto la curva in globale (dovrebbe già avere riferimento globale)
pGuide->ToGlob( frGdL) ;
// recupero gli estremi della linea guida
pGuide->GetStartPoint( ptGdStart) ;
@@ -2222,14 +2222,14 @@ SawFinishing::CalcAlongZigZagCut( const Point3d& ptStart, const Point3d& ptEnd,
if ( AddLinearMove( ptNewStart) == GDB_ID_NULL)
return false ;
}
// se il precedente è più fuori
// se il precedente è più fuori
else if ( dDiff > 0) {
// allungo nuova passata
SetFeed( ( bVert ? GetVertFeed() : GetFeed())) ;
if ( AddLinearMove( ptNewStart - dDiff * vtNewDir) == GDB_ID_NULL)
return false ;
}
// se il corrente è più fuori
// se il corrente è più fuori
else {
// allungo passata precedente
if ( AddLinearMove( ptLast + dDiff * vtNewDir) == GDB_ID_NULL)
@@ -2598,7 +2598,7 @@ SawFinishing::CalcCurvedAlongZigZagCut( const ICurve* pCut, const Vector3d& vtTo
GetCurrPos( ptCurr) ;
// differenza tra corrente e nuovo lungo direzione ortogonale
double dOrtStartDiff = ( ptNewStart - ptCurr) * vtOrtStart ;
// se punto corrente più fuori, aggiungo punto fuori allo stesso modo sul nuovo
// se punto corrente più fuori, aggiungo punto fuori allo stesso modo sul nuovo
if ( dOrtStartDiff < - 10 * EPS_SMALL) {
Point3d ptOut = ptNewStart + ( - dOrtStartDiff * vtOrtStart) ;
SetFlag( 0) ;
@@ -2606,7 +2606,7 @@ SawFinishing::CalcCurvedAlongZigZagCut( const ICurve* pCut, const Vector3d& vtTo
if ( ! SameAsCurrPos( ptOut) && AddLinearMove( ptOut) == GDB_ID_NULL)
return false ;
}
// se altrimenti più dentro, aggiungo punto fuori allo stesso modo sul corrente
// se altrimenti più dentro, aggiungo punto fuori allo stesso modo sul corrente
else if ( dOrtStartDiff > 10 * EPS_SMALL) {
Point3d ptOut = ptCurr + ( dOrtStartDiff * vtOrtStart) ;
SetFlag( 0) ;
@@ -2641,14 +2641,14 @@ SawFinishing::CalcCurvedAlongZigZagCut( const ICurve* pCut, const Vector3d& vtTo
if ( AddLinearMove( ptNewStart) == GDB_ID_NULL)
return false ;
}
// se il precedente è più fuori
// se il precedente è più fuori
else if ( dDiff > 0) {
// allungo nuova passata
SetFeed( ( bVert ? GetVertFeed() : GetFeed())) ;
if ( AddLinearMove( ptNewStart - dDiff * vtDirStart) == GDB_ID_NULL)
return false ;
}
// se il corrente è più fuori
// se il corrente è più fuori
else {
// allungo passata precedente
if ( AddLinearMove( ptLast + dDiff * vtDirStart) == GDB_ID_NULL)
@@ -2660,7 +2660,7 @@ SawFinishing::CalcCurvedAlongZigZagCut( const ICurve* pCut, const Vector3d& vtTo
}
}
}
// se non ci sono già, vado all'inizio dell'arco
// se non ci sono già, vado all'inizio dell'arco
if ( ! SameAsCurrPos( ptStart) && AddLinearMove( ptStart) == GDB_ID_NULL)
return false ;
// 3 -> movimento di lato al punto finale
@@ -2822,7 +2822,7 @@ SawFinishing::AddCornerApproach( const Point3d& ptP, const Vector3d& vtCorr, con
{
// impongo minima distanza di approccio
dAppr = max( dAppr, 1.0) ;
// recupero posizione precedente (correzione precedente è passata perchè già impostata la nuova)
// recupero posizione precedente (correzione precedente è passata perchè già impostata la nuova)
Point3d ptPrev ;
if ( ! GetCurrPos( ptPrev))
return false ;
@@ -2933,7 +2933,7 @@ SawFinishing::GetHeightOnSection( const ICurve* pSect, double dX, double dYmin,
dY = aInfo.IciA[0].ptI.y ;
return true ;
}
// se non c'è intersezione assegno il minimo
// se non c'è intersezione assegno il minimo
dY = dYmin ;
return true ;
}