EgtExecutor 1.6j4 :

- modifiche per gestione DB utensili e generatore codice CN.
This commit is contained in:
Dario Sassi
2015-10-31 09:46:49 +00:00
parent ceef9cb3ac
commit 0f7805a9a1
4 changed files with 561 additions and 432 deletions
+190 -146
View File
@@ -219,7 +219,7 @@ ExeGetCurrMachGroup( void)
}
//-----------------------------------------------------------------------------
// Raw Parts
// Raw Parts & Parts
//-----------------------------------------------------------------------------
int
ExeGetRawPartCount( void)
@@ -594,146 +594,26 @@ ExeShowOnlyTable( bool bVal)
//-----------------------------------------------------------------------------
int
ExeAddSubPiece( const string& sName, const Point3d& ptPos, double dAngRotDeg)
ExeAddFixture( const string& sName, const Point3d& ptPos, double dAngRotDeg)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// inserisco il sottopezzo nella posizione indicata
return pGseCtx->m_pMachMgr->AddSubPiece( sName, ptPos, dAngRotDeg) ;
}
//-----------------------------------------------------------------------------
// Machine Calc
//-----------------------------------------------------------------------------
bool
ExeSetAxisPos( const string& sAxis, double dVal)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// metto l'asse nella nuova posizione
return pGseCtx->m_pMachMgr->SetAxisPos( sAxis, dVal) ;
}
//-----------------------------------------------------------------------------
bool
ExeGetAxisPos( const string& sAxis, double* pdVal)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// verifico il parametro di ritorno
if ( pdVal == nullptr)
return false ;
// metto l'asse nella nuova posizione
return pGseCtx->m_pMachMgr->GetAxisPos( sAxis, *pdVal) ;
}
//-----------------------------------------------------------------------------
bool
ExeGetAxisHomePos( const string& sAxis, double* pdHomeVal)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// verifico il parametro di ritorno
if ( pdHomeVal == nullptr)
return false ;
// metto l'asse nella nuova posizione
return pGseCtx->m_pMachMgr->GetAxisHomePos( sAxis, *pdHomeVal) ;
}
//-----------------------------------------------------------------------------
bool
ExeResetAxisPos( const string& sAxis)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// metto l'asse nella posizione home
return pGseCtx->m_pMachMgr->ResetAxisPos( sAxis) ;
}
//-----------------------------------------------------------------------------
bool
ExeLoadTool( const string& sHead, int nExit, const string& sTool)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// carico l'utensile sulla macchina della macchinata corrente in posizione indicata
return pGseCtx->m_pMachMgr->LoadTool( sHead, nExit, sTool) ;
}
//-----------------------------------------------------------------------------
bool
ExeResetHeadSet( const string& sHead)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// carico l'utensile sulla macchina della macchinata corrente in posizione indicata
return pGseCtx->m_pMachMgr->ResetHeadSet( sHead) ;
}
//-----------------------------------------------------------------------------
bool
ExeSetCalcTable( const std::string& sTable)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// imposto la tavola corrente della macchinata corrente per i calcoli
return pGseCtx->m_pMachMgr->SetCalcTable( sTable) ;
}
//-----------------------------------------------------------------------------
bool
ExeSetCalcTool( const std::string& sTool, const std::string& sHead, int nExit)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// imposto l'utensile corrente per il calcolo sulla macchina della macchinata corrente
return pGseCtx->m_pMachMgr->SetCalcTool( sTool, sHead, nExit) ;
}
//-----------------------------------------------------------------------------
bool
ExeGetCalcTool( std::string& sTool)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// restituisco il nome dell'utensile corrente per il calcolo sulla macchina della macchinata corrente
return pGseCtx->m_pMachMgr->GetCalcTool( sTool) ;
}
//-----------------------------------------------------------------------------
bool
ExeGetCalcAngles( const Vector3d& vtDirT, const Vector3d& vtDirA,
int& nStat, double& dAngA1, double& dAngB1, double& dAngA2, double& dAngB2)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// calcolo gli angoli macchina dalle direzioni fresa e ausiliaria passate
return pGseCtx->m_pMachMgr->GetCalcAngles( vtDirT, vtDirA, nStat, dAngA1, dAngB1, dAngA2, dAngB2) ;
}
//-----------------------------------------------------------------------------
bool
ExeGetCalcPositions( const Point3d& ptP, double dAngA, double dAngB,
int& nStat, double& dX, double& dY, double& dZ)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// calcolo gli angoli macchina dalla direzione fresa passata
return pGseCtx->m_pMachMgr->GetCalcPositions( ptP, dAngA, dAngB, nStat, dX, dY, dZ) ;
}
//-----------------------------------------------------------------------------
bool
ExeVerifyOutOfStroke( double dX, double dY, double dZ, double dAngA, double dAngB, int& nStat)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// verifica l'extracorsa degli assi
return pGseCtx->m_pMachMgr->VerifyOutOfStroke( dX, dY, dZ, dAngA, dAngB, nStat) ;
// inserisco il dispositivo di presa nella posizione indicata
return pGseCtx->m_pMachMgr->AddFixture( sName, ptPos, dAngRotDeg) ;
}
//-----------------------------------------------------------------------------
// DB utensili
//-----------------------------------------------------------------------------
bool
ExeTdbGetToolNewName( string& sName)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// recupero un nuovo nome a partire da quello passato
return pGseCtx->m_pMachMgr->TdbGetToolNewName( sName) ;
}
//-----------------------------------------------------------------------------
bool
ExeTdbAddTool( const string& sName, int nType)
@@ -786,62 +666,82 @@ ExeTdbGetNextTool( int nFamily, string& sName, int& nType)
//-----------------------------------------------------------------------------
bool
ExeTdbSetToolParam( const string& sName, int nType, int nVal)
ExeTdbSetCurrTool( const std::string& sName)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// imposta il parametro dell'utensile
return pGseCtx->m_pMachMgr->TdbSetToolParam( sName, nType, nVal) ;
return pGseCtx->m_pMachMgr->TdbSetCurrTool( sName) ;
}
//-----------------------------------------------------------------------------
bool
ExeTdbSetToolParam( const string& sName, int nType, double dVal)
ExeTdbSaveCurrTool( void)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// imposta il parametro dell'utensile
return pGseCtx->m_pMachMgr->TdbSaveCurrTool() ;
}
//-----------------------------------------------------------------------------
bool
ExeTdbSetCurrToolParam( int nType, int nVal)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// imposta il parametro dell'utensile
return pGseCtx->m_pMachMgr->TdbSetCurrToolParam( nType, nVal) ;
}
//-----------------------------------------------------------------------------
bool
ExeTdbSetCurrToolParam( int nType, double dVal)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// imposto il parametro dell'utensile
return pGseCtx->m_pMachMgr->TdbSetToolParam( sName, nType, dVal) ;
return pGseCtx->m_pMachMgr->TdbSetCurrToolParam( nType, dVal) ;
}
//-----------------------------------------------------------------------------
bool
ExeTdbSetToolParam( const string& sName, int nType, const string& sVal)
ExeTdbSetCurrToolParam( int nType, const string& sVal)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// imposto il parametro dell'utensile
return pGseCtx->m_pMachMgr->TdbSetToolParam( sName, nType, sVal) ;
return pGseCtx->m_pMachMgr->TdbSetCurrToolParam( nType, sVal) ;
}
//-----------------------------------------------------------------------------
bool
ExeTdbGetToolParam( const string& sName, int nType, int& nVal)
ExeTdbGetCurrToolParam( int nType, int& nVal)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// recupero il parametro dell'utensile
return pGseCtx->m_pMachMgr->TdbGetToolParam( sName, nType, nVal) ;
return pGseCtx->m_pMachMgr->TdbGetCurrToolParam( nType, nVal) ;
}
//-----------------------------------------------------------------------------
bool
ExeTdbGetToolParam( const string& sName, int nType, double& dVal)
ExeTdbGetCurrToolParam( int nType, double& dVal)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// recupero il parametro dell'utensile
return pGseCtx->m_pMachMgr->TdbGetToolParam( sName, nType, dVal) ;
return pGseCtx->m_pMachMgr->TdbGetCurrToolParam( nType, dVal) ;
}
//-----------------------------------------------------------------------------
bool
ExeTdbGetToolParam( const string& sName, int nType, string& sVal)
ExeTdbGetCurrToolParam( int nType, string& sVal)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// recupero il parametro dell'utensile
return pGseCtx->m_pMachMgr->TdbGetToolParam( sName, nType, sVal) ;
return pGseCtx->m_pMachMgr->TdbGetCurrToolParam( nType, sVal) ;
}
//-----------------------------------------------------------------------------
@@ -1019,3 +919,147 @@ ExeSimStop( void)
// termino la simulazione della macchinata corrente
return pGseCtx->m_pMachMgr->SimStop() ;
}
//-----------------------------------------------------------------------------
// Generazione
//-----------------------------------------------------------------------------
bool
ExeGenerate( const string& sCncFile)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// avvio la generazione del partprogram della macchinata corrente
return pGseCtx->m_pMachMgr->Generate( sCncFile) ;
}
//-----------------------------------------------------------------------------
// Machine Calc
//-----------------------------------------------------------------------------
bool
ExeSetCalcTable( const std::string& sTable)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// imposto la tavola corrente della macchinata corrente per i calcoli
return pGseCtx->m_pMachMgr->SetCalcTable( sTable) ;
}
//-----------------------------------------------------------------------------
bool
ExeSetCalcTool( const std::string& sTool, const std::string& sHead, int nExit)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// imposto l'utensile corrente per il calcolo sulla macchina della macchinata corrente
return pGseCtx->m_pMachMgr->SetCalcTool( sTool, sHead, nExit) ;
}
//-----------------------------------------------------------------------------
bool
ExeGetCalcTool( std::string& sTool)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// restituisco il nome dell'utensile corrente per il calcolo sulla macchina della macchinata corrente
return pGseCtx->m_pMachMgr->GetCalcTool( sTool) ;
}
//-----------------------------------------------------------------------------
bool
ExeGetCalcAngles( const Vector3d& vtDirT, const Vector3d& vtDirA,
int& nStat, double& dAngA1, double& dAngB1, double& dAngA2, double& dAngB2)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// calcolo gli angoli macchina dalle direzioni fresa e ausiliaria passate
return pGseCtx->m_pMachMgr->GetCalcAngles( vtDirT, vtDirA, nStat, dAngA1, dAngB1, dAngA2, dAngB2) ;
}
//-----------------------------------------------------------------------------
bool
ExeGetCalcPositions( const Point3d& ptP, double dAngA, double dAngB,
int& nStat, double& dX, double& dY, double& dZ)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// calcolo gli angoli macchina dalla direzione fresa passata
return pGseCtx->m_pMachMgr->GetCalcPositions( ptP, dAngA, dAngB, nStat, dX, dY, dZ) ;
}
//-----------------------------------------------------------------------------
bool
ExeVerifyOutOfStroke( double dX, double dY, double dZ, double dAngA, double dAngB, int& nStat)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// verifica l'extracorsa degli assi
return pGseCtx->m_pMachMgr->VerifyOutOfStroke( dX, dY, dZ, dAngA, dAngB, nStat) ;
}
//-----------------------------------------------------------------------------
// Machine Move
//-----------------------------------------------------------------------------
bool
ExeSetAxisPos( const string& sAxis, double dVal)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// metto l'asse nella nuova posizione
return pGseCtx->m_pMachMgr->SetAxisPos( sAxis, dVal) ;
}
//-----------------------------------------------------------------------------
bool
ExeGetAxisPos( const string& sAxis, double* pdVal)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// verifico il parametro di ritorno
if ( pdVal == nullptr)
return false ;
// metto l'asse nella nuova posizione
return pGseCtx->m_pMachMgr->GetAxisPos( sAxis, *pdVal) ;
}
//-----------------------------------------------------------------------------
bool
ExeGetAxisHomePos( const string& sAxis, double* pdHomeVal)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// verifico il parametro di ritorno
if ( pdHomeVal == nullptr)
return false ;
// metto l'asse nella nuova posizione
return pGseCtx->m_pMachMgr->GetAxisHomePos( sAxis, *pdHomeVal) ;
}
//-----------------------------------------------------------------------------
bool
ExeResetAxisPos( const string& sAxis)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// metto l'asse nella posizione home
return pGseCtx->m_pMachMgr->ResetAxisPos( sAxis) ;
}
//-----------------------------------------------------------------------------
bool
ExeLoadTool( const string& sHead, int nExit, const string& sTool)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// carico l'utensile sulla macchina della macchinata corrente in posizione indicata
return pGseCtx->m_pMachMgr->LoadTool( sHead, nExit, sTool) ;
}
//-----------------------------------------------------------------------------
bool
ExeResetHeadSet( const string& sHead)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// carico l'utensile sulla macchina della macchinata corrente in posizione indicata
return pGseCtx->m_pMachMgr->ResetHeadSet( sHead) ;
}
BIN
View File
Binary file not shown.
+18
View File
@@ -90,6 +90,23 @@ LuaGetGridVersZ( lua_State* L)
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaGetCurrFilePath( lua_State* L)
{
// nessun parametro
LuaClearStack( L) ;
// recupero la path del file corrente
string sFilePath ;
bool bOk = ExeGetCurrFilePath( sFilePath) ;
// restituisco il risultato
if ( bOk)
LuaSetParam( L, sFilePath) ;
else
LuaSetParam( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaNewFile( lua_State* L)
@@ -178,6 +195,7 @@ LuaInstallGeomDB( LuaMgr& luaMgr)
bOk = bOk && luaMgr.RegisterFunction( "EgtSetGridFrame", LuaSetGridFrame) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetGridFrame", LuaGetGridFrame) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetGridVersZ", LuaGetGridVersZ) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetCurrFilePath", LuaGetCurrFilePath) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtNewFile", LuaNewFile) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtOpenFile", LuaOpenFile) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtInsertFile", LuaInsertFile) ;
+353 -286
View File
@@ -579,7 +579,7 @@ LuaGetTableRef1( lua_State* L)
//-------------------------------------------------------------------------------
static int
LuaAddSubPiece( lua_State* L)
LuaAddFixture( lua_State* L)
{
// 2 o 3 parametri : sName, ptPos [, dAngRotDeg]
string sName ;
@@ -590,7 +590,7 @@ LuaAddSubPiece( lua_State* L)
LuaGetParam( L, 3, dAngRotDeg) ;
LuaClearStack( L) ;
// metto l'asse nella nuova posizione
int nId = ExeAddSubPiece( sName, ptPos, dAngRotDeg) ;
int nId = ExeAddFixture( sName, ptPos, dAngRotDeg) ;
// restituisco il risultato
if ( nId != GDB_ID_NULL)
LuaSetParam( L, nId) ;
@@ -601,249 +601,21 @@ LuaAddSubPiece( lua_State* L)
//-------------------------------------------------------------------------------
static int
LuaSetAxisPos( lua_State* L)
LuaTdbGetToolNewName( lua_State* L)
{
// 2 parametri : sAxis, dVal
string sAxis ;
LuaCheckParam( L, 1, sAxis)
double dVal ;
LuaCheckParam( L, 2, dVal)
// 1 parametro : sName
string sName ;
LuaCheckParam( L, 1, sName)
LuaClearStack( L) ;
// metto l'asse nella nuova posizione
bool bOk = ExeSetAxisPos( sAxis, dVal) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaGetAxisPos( lua_State* L)
{
// 1 parametro : sAxis
string sAxis ;
LuaCheckParam( L, 1, sAxis)
LuaClearStack( L) ;
// recupero la posizione dell'asse
double dVal ;
bool bOk = ExeGetAxisPos( sAxis, &dVal) ;
// restituisco il risultato
// verifico nome e se necessario lo modifico per renderlo nuovo nel DB
bool bOk = ExeTdbGetToolNewName( sName) ;
if ( bOk)
LuaSetParam( L, dVal) ;
LuaSetParam( L, sName) ;
else
LuaSetParam( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaGetAxisHomePos( lua_State* L)
{
// 1 parametro : sAxis
string sAxis ;
LuaCheckParam( L, 1, sAxis)
LuaClearStack( L) ;
// recupero la posizione dell'asse
double dHomeVal ;
bool bOk = ExeGetAxisHomePos( sAxis, &dHomeVal) ;
// restituisco il risultato
if ( bOk)
LuaSetParam( L, dHomeVal) ;
else
LuaSetParam( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaResetAxisPos( lua_State* L)
{
// 1 parametro : sAxis
string sAxis ;
LuaCheckParam( L, 1, sAxis)
LuaClearStack( L) ;
// metto l'asse nella posizione home
bool bOk = ExeResetAxisPos( sAxis) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaLoadTool( lua_State* L)
{
// 3 parametri : sHead, nExit, sTool
string sHead ;
LuaCheckParam( L, 1, sHead)
int nExit ;
LuaCheckParam( L, 2, nExit)
string sTool ;
LuaCheckParam( L, 3, sTool)
LuaClearStack( L) ;
// carico l'utensile
bool bOk = ExeLoadTool( sHead, nExit, sTool) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaResetHeadSet( lua_State* L)
{
// 1 parametro : sHead
string sHead ;
LuaCheckParam( L, 1, sHead)
LuaClearStack( L) ;
// carico l'utensile
bool bOk = ExeResetHeadSet( sHead) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaSetCalcTable( lua_State* L)
{
// 1 parametro : sTable
string sTable ;
LuaCheckParam( L, 1, sTable)
LuaClearStack( L) ;
// imposto la tavola corrente per i calcoli macchina
bool bOk = ExeSetCalcTable( sTable) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaSetCalcTool( lua_State* L)
{
// 3 parametro : sTool, sHead, nExit
string sTool ;
LuaCheckParam( L, 1, sTool)
string sHead ;
LuaCheckParam( L, 2, sHead)
int nExit ;
LuaCheckParam( L, 3, nExit)
LuaClearStack( L) ;
// imposto l'utensile corrente per il calcolo
bool bOk = ExeSetCalcTool( sTool, sHead, nExit) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaGetCalcTool( lua_State* L)
{
// nessun parametro
LuaClearStack( L) ;
// recupero l'utensile corrente
string sTool ;
bool bOk = ExeGetCalcTool( sTool) ;
// restituisco il risultato
if ( bOk)
LuaSetParam( L, sTool) ;
else
LuaSetParam( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaGetCalcAngles( lua_State* L)
{
// 1 o 2 parametri : vtDirT, vtDirA
Vector3d vtDirT ;
LuaCheckParam( L, 1, vtDirT)
Vector3d vtDirA ;
LuaGetParam( L, 2, vtDirA) ;
LuaClearStack( L) ;
// imposto la tavola corrente per il calcolo
int nStat ; double dAngA1 ; double dAngB1 ; double dAngA2 ; double dAngB2 ;
bool bOk = ExeGetCalcAngles( vtDirT, vtDirA, nStat, dAngA1, dAngB1, dAngA2, dAngB2) ;
// restituisco il risultato
if ( bOk) {
LuaSetParam( L, bOk) ;
LuaSetParam( L, nStat) ;
LuaSetParam( L, dAngA1) ;
LuaSetParam( L, dAngB1) ;
LuaSetParam( L, dAngA2) ;
LuaSetParam( L, dAngB2) ;
return 6 ;
}
else {
LuaSetParam( L, bOk) ;
return 1 ;
}
}
//-------------------------------------------------------------------------------
static int
LuaGetCalcPositions( lua_State* L)
{
// 3 parametri : ptP, dAngA, dAngB
Point3d ptP ;
LuaCheckParam( L, 1, ptP)
double dAngA ;
LuaCheckParam( L, 2, dAngA)
double dAngB ;
LuaCheckParam( L, 3, dAngB)
LuaClearStack( L) ;
// imposto la tavola corrente per il calcolo
int nStat ; double dX ; double dY ; double dZ ;
bool bOk = ExeGetCalcPositions( ptP, dAngA, dAngB, nStat, dX, dY, dZ) ;
// restituisco il risultato
if ( bOk) {
LuaSetParam( L, bOk) ;
LuaSetParam( L, nStat) ;
LuaSetParam( L, dX) ;
LuaSetParam( L, dY) ;
LuaSetParam( L, dZ) ;
return 5 ;
}
else {
LuaSetParam( L, bOk) ;
return 1 ;
}
}
//-------------------------------------------------------------------------------
static int
LuaVerifyOutOfStroke( lua_State* L)
{
// 5 parametri : dX, dY, dZ, dAngA, dAngB
double dX ;
LuaCheckParam( L, 1, dX)
double dY ;
LuaCheckParam( L, 2, dY)
double dZ ;
LuaCheckParam( L, 3, dZ)
double dAngA ;
LuaCheckParam( L, 4, dAngA)
double dAngB ;
LuaCheckParam( L, 5, dAngB)
LuaClearStack( L) ;
// imposto la tavola corrente per il calcolo
int nStat ;
bool bOk = ExeVerifyOutOfStroke( dX, dY, dZ, dAngA, dAngB, nStat) ;
// restituisco il risultato
if ( bOk) {
LuaSetParam( L, bOk) ;
LuaSetParam( L, nStat) ;
return 2 ;
}
else {
LuaSetParam( L, bOk) ;
return 1 ;
}
}
//-------------------------------------------------------------------------------
static int
LuaTdbAddTool( lua_State* L)
@@ -938,33 +710,57 @@ LuaTdbGetNextTool( lua_State* L)
//-------------------------------------------------------------------------------
static int
LuaTdbSetToolParam( lua_State* L)
LuaTdbSetCurrTool( lua_State* L)
{
// 3 parametri : sName, nType, Val
// 1 parametro : sName
string sName ;
LuaCheckParam( L, 1, sName)
LuaClearStack( L) ;
// imposto l'utensile corrente
bool bOk = ExeTdbSetCurrTool( sName) ;
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaTdbSaveCurrTool( lua_State* L)
{
// nessun parametro
LuaClearStack( L) ;
// salvo l'utensile corrente
bool bOk = ExeTdbSaveCurrTool() ;
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaTdbSetCurrToolParam( lua_State* L)
{
// 2 parametri : nType, Val
int nType ;
LuaCheckParam( L, 2, nType)
LuaCheckParam( L, 1, nType)
// leggo opportunamente il valore da assegnare
if ( ( nType & TPA_INT) != 0) {
int nVal ;
LuaCheckParam( L, 3, nVal)
LuaCheckParam( L, 2, nVal)
LuaClearStack( L) ;
bool bOk = ExeTdbSetToolParam( sName, nType, nVal) ;
bool bOk = ExeTdbSetCurrToolParam( nType, nVal) ;
LuaSetParam( L, bOk) ;
}
else if ( ( nType & TPA_DOU) != 0) {
double dVal ;
LuaCheckParam( L, 3, dVal)
LuaCheckParam( L, 2, dVal)
LuaClearStack( L) ;
bool bOk = ExeTdbSetToolParam( sName, nType, dVal) ;
bool bOk = ExeTdbSetCurrToolParam( nType, dVal) ;
LuaSetParam( L, bOk) ;
}
else if ( ( nType & TPA_STR) != 0) {
string sVal ;
LuaCheckParam( L, 3, sVal)
LuaCheckParam( L, 2, sVal)
LuaClearStack( L) ;
bool bOk = ExeTdbSetToolParam( sName, nType, sVal) ;
bool bOk = ExeTdbSetCurrToolParam( nType, sVal) ;
LuaSetParam( L, bOk) ;
}
else
@@ -974,18 +770,16 @@ LuaTdbSetToolParam( lua_State* L)
//-------------------------------------------------------------------------------
static int
LuaTdbGetToolParam( lua_State* L)
LuaTdbGetCurrToolParam( lua_State* L)
{
// 2 parametri : sName, nType
string sName ;
LuaCheckParam( L, 1, sName)
// 1 parametr : nType
int nType ;
LuaCheckParam( L, 2, nType)
LuaCheckParam( L, 1, nType)
LuaClearStack( L) ;
// recupero il parametro dell'utensile voluto
if ( ( nType & TPA_INT) != 0) {
int nVal ;
bool bOk = ExeTdbGetToolParam( sName, nType, nVal) ;
bool bOk = ExeTdbGetCurrToolParam( nType, nVal) ;
if ( bOk)
LuaSetParam( L, nVal) ;
else
@@ -993,7 +787,7 @@ LuaTdbGetToolParam( lua_State* L)
}
else if ( ( nType & TPA_DOU) != 0) {
double dVal ;
bool bOk = ExeTdbGetToolParam( sName, nType, dVal) ;
bool bOk = ExeTdbGetCurrToolParam( nType, dVal) ;
if ( bOk)
LuaSetParam( L, dVal) ;
else
@@ -1001,7 +795,7 @@ LuaTdbGetToolParam( lua_State* L)
}
else if ( ( nType & TPA_STR) != 0) {
string sVal ;
bool bOk = ExeTdbGetToolParam( sName, nType, sVal) ;
bool bOk = ExeTdbGetCurrToolParam( nType, sVal) ;
if ( bOk)
LuaSetParam( L, sVal) ;
else
@@ -1239,12 +1033,274 @@ LuaSimStop( lua_State* L)
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaGenerate( lua_State* L)
{
// 1 parametro : sCncFile
string sCncFile ;
LuaCheckParam( L, 1, sCncFile)
LuaClearStack( L) ;
// termino la simulazione
bool bOk = ExeGenerate( sCncFile) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaSetCalcTable( lua_State* L)
{
// 1 parametro : sTable
string sTable ;
LuaCheckParam( L, 1, sTable)
LuaClearStack( L) ;
// imposto la tavola corrente per i calcoli macchina
bool bOk = ExeSetCalcTable( sTable) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaSetCalcTool( lua_State* L)
{
// 3 parametro : sTool, sHead, nExit
string sTool ;
LuaCheckParam( L, 1, sTool)
string sHead ;
LuaCheckParam( L, 2, sHead)
int nExit ;
LuaCheckParam( L, 3, nExit)
LuaClearStack( L) ;
// imposto l'utensile corrente per il calcolo
bool bOk = ExeSetCalcTool( sTool, sHead, nExit) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaGetCalcTool( lua_State* L)
{
// nessun parametro
LuaClearStack( L) ;
// recupero l'utensile corrente
string sTool ;
bool bOk = ExeGetCalcTool( sTool) ;
// restituisco il risultato
if ( bOk)
LuaSetParam( L, sTool) ;
else
LuaSetParam( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaGetCalcAngles( lua_State* L)
{
// 1 o 2 parametri : vtDirT, vtDirA
Vector3d vtDirT ;
LuaCheckParam( L, 1, vtDirT)
Vector3d vtDirA ;
LuaGetParam( L, 2, vtDirA) ;
LuaClearStack( L) ;
// imposto la tavola corrente per il calcolo
int nStat ; double dAngA1 ; double dAngB1 ; double dAngA2 ; double dAngB2 ;
bool bOk = ExeGetCalcAngles( vtDirT, vtDirA, nStat, dAngA1, dAngB1, dAngA2, dAngB2) ;
// restituisco il risultato
if ( bOk) {
LuaSetParam( L, bOk) ;
LuaSetParam( L, nStat) ;
LuaSetParam( L, dAngA1) ;
LuaSetParam( L, dAngB1) ;
LuaSetParam( L, dAngA2) ;
LuaSetParam( L, dAngB2) ;
return 6 ;
}
else {
LuaSetParam( L, bOk) ;
return 1 ;
}
}
//-------------------------------------------------------------------------------
static int
LuaGetCalcPositions( lua_State* L)
{
// 3 parametri : ptP, dAngA, dAngB
Point3d ptP ;
LuaCheckParam( L, 1, ptP)
double dAngA ;
LuaCheckParam( L, 2, dAngA)
double dAngB ;
LuaCheckParam( L, 3, dAngB)
LuaClearStack( L) ;
// imposto la tavola corrente per il calcolo
int nStat ; double dX ; double dY ; double dZ ;
bool bOk = ExeGetCalcPositions( ptP, dAngA, dAngB, nStat, dX, dY, dZ) ;
// restituisco il risultato
if ( bOk) {
LuaSetParam( L, bOk) ;
LuaSetParam( L, nStat) ;
LuaSetParam( L, dX) ;
LuaSetParam( L, dY) ;
LuaSetParam( L, dZ) ;
return 5 ;
}
else {
LuaSetParam( L, bOk) ;
return 1 ;
}
}
//-------------------------------------------------------------------------------
static int
LuaVerifyOutOfStroke( lua_State* L)
{
// 5 parametri : dX, dY, dZ, dAngA, dAngB
double dX ;
LuaCheckParam( L, 1, dX)
double dY ;
LuaCheckParam( L, 2, dY)
double dZ ;
LuaCheckParam( L, 3, dZ)
double dAngA ;
LuaCheckParam( L, 4, dAngA)
double dAngB ;
LuaCheckParam( L, 5, dAngB)
LuaClearStack( L) ;
// imposto la tavola corrente per il calcolo
int nStat ;
bool bOk = ExeVerifyOutOfStroke( dX, dY, dZ, dAngA, dAngB, nStat) ;
// restituisco il risultato
if ( bOk) {
LuaSetParam( L, bOk) ;
LuaSetParam( L, nStat) ;
return 2 ;
}
else {
LuaSetParam( L, bOk) ;
return 1 ;
}
}
//-------------------------------------------------------------------------------
static int
LuaSetAxisPos( lua_State* L)
{
// 2 parametri : sAxis, dVal
string sAxis ;
LuaCheckParam( L, 1, sAxis)
double dVal ;
LuaCheckParam( L, 2, dVal)
LuaClearStack( L) ;
// metto l'asse nella nuova posizione
bool bOk = ExeSetAxisPos( sAxis, dVal) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaGetAxisPos( lua_State* L)
{
// 1 parametro : sAxis
string sAxis ;
LuaCheckParam( L, 1, sAxis)
LuaClearStack( L) ;
// recupero la posizione dell'asse
double dVal ;
bool bOk = ExeGetAxisPos( sAxis, &dVal) ;
// restituisco il risultato
if ( bOk)
LuaSetParam( L, dVal) ;
else
LuaSetParam( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaGetAxisHomePos( lua_State* L)
{
// 1 parametro : sAxis
string sAxis ;
LuaCheckParam( L, 1, sAxis)
LuaClearStack( L) ;
// recupero la posizione dell'asse
double dHomeVal ;
bool bOk = ExeGetAxisHomePos( sAxis, &dHomeVal) ;
// restituisco il risultato
if ( bOk)
LuaSetParam( L, dHomeVal) ;
else
LuaSetParam( L) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaResetAxisPos( lua_State* L)
{
// 1 parametro : sAxis
string sAxis ;
LuaCheckParam( L, 1, sAxis)
LuaClearStack( L) ;
// metto l'asse nella posizione home
bool bOk = ExeResetAxisPos( sAxis) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaLoadTool( lua_State* L)
{
// 3 parametri : sHead, nExit, sTool
string sHead ;
LuaCheckParam( L, 1, sHead)
int nExit ;
LuaCheckParam( L, 2, nExit)
string sTool ;
LuaCheckParam( L, 3, sTool)
LuaClearStack( L) ;
// carico l'utensile
bool bOk = ExeLoadTool( sHead, nExit, sTool) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaResetHeadSet( lua_State* L)
{
// 1 parametro : sHead
string sHead ;
LuaCheckParam( L, 1, sHead)
LuaClearStack( L) ;
// carico l'utensile
bool bOk = ExeResetHeadSet( sHead) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
bool
LuaInstallMachMgr( LuaMgr& luaMgr)
{
bool bOk = ( &luaMgr != nullptr) ;
// Machines
bOk = bOk && luaMgr.RegisterFunction( "EgtSetCurrMachine", LuaSetCurrMachine) ;
// Mach Groups
bOk = bOk && luaMgr.RegisterFunction( "EgtGetMachGroupCount", LuaGetMachGroupCount) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetFirstMachGroup", LuaGetFirstMachGroup) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetNextMachGroup", LuaGetNextMachGroup) ;
@@ -1255,6 +1311,7 @@ LuaInstallMachMgr( LuaMgr& luaMgr)
bOk = bOk && luaMgr.RegisterFunction( "EgtSetCurrMachGroup", LuaSetCurrMachGroup) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtResetCurrMachGroup", LuaResetCurrMachGroup) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetCurrMachGroup", LuaGetCurrMachGroup) ;
// Raw Parts & Parts
bOk = bOk && luaMgr.RegisterFunction( "EgtGetRawPartCount", LuaGetRawPartCount) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetFirstRawPart", LuaGetFirstRawPart) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetNextRawPart", LuaGetNextRawPart) ;
@@ -1274,46 +1331,56 @@ LuaInstallMachMgr( LuaMgr& luaMgr)
bOk = bOk && luaMgr.RegisterFunction( "EgtRemovePartFromRawPart", LuaRemovePartFromRawPart) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtMovePartInRawPart", LuaTranslatePartInRawPart) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtRotatePartInRawPart", LuaRotatePartInRawPart) ;
// Table & Fixtures
bOk = bOk && luaMgr.RegisterFunction( "EgtSetTable", LuaSetTable) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetTableRef1", LuaGetTableRef1) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtAddSubPiece", LuaAddSubPiece) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSetAxisPos", LuaSetAxisPos) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetAxisPos", LuaGetAxisPos) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetAxisHomePos", LuaGetAxisHomePos) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtResetAxisPos", LuaResetAxisPos) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtLoadTool", LuaLoadTool) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtResetHeadSet", LuaResetHeadSet) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtAddFixture", LuaAddFixture) ;
// Tools database
bOk = bOk && luaMgr.RegisterFunction( "EgtTdbGetToolNewName", LuaTdbGetToolNewName) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtTdbAddTool", LuaTdbAddTool) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtTdbCopyTool", LuaTdbCopyTool) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtTdbRemoveTool", LuaTdbRemoveTool) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtTdbGetFirstTool", LuaTdbGetFirstTool) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtTdbGetNextTool", LuaTdbGetNextTool) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtTdbSetCurrTool", LuaTdbSetCurrTool) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtTdbSaveCurrTool", LuaTdbSaveCurrTool) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtTdbSetCurrToolParam", LuaTdbSetCurrToolParam) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtTdbGetCurrToolParam", LuaTdbGetCurrToolParam) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtTdbSave", LuaTdbSave) ;
// Machinings database
// ...
// Operations
bOk = bOk && luaMgr.RegisterFunction( "EgtGetFirstOperation", LuaGetFirstOperation) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetNextOperation", LuaGetNextOperation) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetOperationType", LuaGetOperationType) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtRemoveAllOperations", LuaRemoveAllOperations) ;
// Machinings
bOk = bOk && luaMgr.RegisterFunction( "EgtAddMachining", LuaAddMachining) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSetMachiningParam", LuaSetMachiningParam) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSetMachiningGeometry", LuaSetMachiningGeometry) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtApplyMachining", LuaApplyMachining) ;
// Simulation
bOk = bOk && luaMgr.RegisterFunction( "EgtSimStart", LuaSimStart) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSimMove", LuaSimMove) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSimHome", LuaSimHome) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSimSetStep", LuaSimSetStep) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSimStop", LuaSimStop) ;
// Generation
bOk = bOk && luaMgr.RegisterFunction( "EgtGenerate", LuaGenerate) ;
// Machine Calc
bOk = bOk && luaMgr.RegisterFunction( "EgtSetCalcTable", LuaSetCalcTable) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSetCalcTool", LuaSetCalcTool) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetCalcTool", LuaGetCalcTool) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetCalcAngles", LuaGetCalcAngles) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetCalcPositions", LuaGetCalcPositions) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtVerifyOutOfStroke", LuaVerifyOutOfStroke) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtTdbAddTool", LuaTdbAddTool) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtTdbCopyTool", LuaTdbCopyTool) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtTdbRemoveTool", LuaTdbRemoveTool) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtTdbGetFirstTool", LuaTdbGetFirstTool) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtTdbGetNextTool", LuaTdbGetNextTool) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtTdbSetToolParam", LuaTdbSetToolParam) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtTdbGetToolParam", LuaTdbGetToolParam) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtTdbSave", LuaTdbSave) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetFirstOperation", LuaGetFirstOperation) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetNextOperation", LuaGetNextOperation) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetOperationType", LuaGetOperationType) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtRemoveAllOperations", LuaRemoveAllOperations) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtAddMachining", LuaAddMachining) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSetMachiningParam", LuaSetMachiningParam) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSetMachiningGeometry", LuaSetMachiningGeometry) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtApplyMachining", LuaApplyMachining) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSimStart", LuaSimStart) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSimMove", LuaSimMove) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSimHome", LuaSimHome) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSimSetStep", LuaSimSetStep) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSimStop", LuaSimStop) ;
// Machine Move
bOk = bOk && luaMgr.RegisterFunction( "EgtSetAxisPos", LuaSetAxisPos) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetAxisPos", LuaGetAxisPos) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetAxisHomePos", LuaGetAxisHomePos) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtResetAxisPos", LuaResetAxisPos) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtLoadTool", LuaLoadTool) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtResetHeadSet", LuaResetHeadSet) ;
return bOk ;
}