EgtExecutor 1.6j3 :

- aggiornamenti per gestione DB utensili
- aggiunta gestione pompa eventi di interfaccia
- aggiunti comandi Lua per copia e rinomina file.
This commit is contained in:
Dario Sassi
2015-10-27 10:14:16 +00:00
parent e3aab825c2
commit 21487cc6f2
6 changed files with 401 additions and 16 deletions
+3
View File
@@ -21,3 +21,6 @@ ILogger* GetLogger( void) ;
ILogger* GetCmdLogger( void) ;
bool SetCmdLog( bool bVal) ;
bool IsCmdLog( void) ;
//----------------------------------------------------------------------------
int ProcessEvents( int nProg, int nPause) ;
+21
View File
@@ -39,6 +39,7 @@ static Logger* s_pGenLog = nullptr ;
static bool s_bCmdLog = false ;
static Logger* s_pCmdLog = nullptr ;
static string s_sKey ;
static pfProcEvents s_pFunProcEvents = nullptr ;
//-----------------------------------------------------------------------------
bool
@@ -326,6 +327,15 @@ ExeOutLog( const string& sMsg)
return ( s_pGenLog != nullptr) ;
}
//-----------------------------------------------------------------------------
bool
ExeSetProcessEvents( pfProcEvents pFun)
{
s_pFunProcEvents = pFun ;
return ( pFun != nullptr) ;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
ILogger*
@@ -355,3 +365,14 @@ IsCmdLog( void)
{
return s_bCmdLog ;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
int
ProcessEvents( int nProg, int nPause)
{
if ( s_pFunProcEvents != nullptr)
return s_pFunProcEvents( nProg, nPause) ;
else
return 0 ;
}
+135 -8
View File
@@ -66,6 +66,20 @@ ExeInsertMachMgr( int nInsGrp)
return pMachMgr->Insert( nInsGrp) ;
}
//-----------------------------------------------------------------------------
// Machines
//-----------------------------------------------------------------------------
bool
ExeSetCurrMachine( const string& sMachineName)
{
IMachMgr* pMachMgr = GetCurrMachMgr() ;
VERIFY_MACHMGR( pMachMgr, false)
// imposto la macchina corrente
return pMachMgr->SetCurrMachine( sMachineName) ;
}
//-----------------------------------------------------------------------------
// Machining Groups
//-----------------------------------------------------------------------------
int
ExeGetMachGroupCount( void)
@@ -204,6 +218,8 @@ ExeGetCurrMachGroup( void)
return pMachMgr->GetCurrMachGroup() ;
}
//-----------------------------------------------------------------------------
// Raw Parts
//-----------------------------------------------------------------------------
int
ExeGetRawPartCount( void)
@@ -534,6 +550,8 @@ ExeRotatePartInRawPart( int nPartId, const Vector3d& vtAx, double dAngRotDeg)
return bOk ;
}
//-----------------------------------------------------------------------------
// Table & Fixtures
//-----------------------------------------------------------------------------
bool
ExeSetTable( const std::string& sTable)
@@ -584,6 +602,8 @@ ExeAddSubPiece( const string& sName, const Point3d& ptPos, double dAngRotDeg)
return pGseCtx->m_pMachMgr->AddSubPiece( sName, ptPos, dAngRotDeg) ;
}
//-----------------------------------------------------------------------------
// Machine Calc
//-----------------------------------------------------------------------------
bool
ExeSetAxisPos( const string& sAxis, double dVal)
@@ -712,36 +732,131 @@ ExeVerifyOutOfStroke( double dX, double dY, double dZ, double dAngA, double dAng
return pGseCtx->m_pMachMgr->VerifyOutOfStroke( dX, dY, dZ, dAngA, dAngB, nStat) ;
}
//-----------------------------------------------------------------------------
// DB utensili
//-----------------------------------------------------------------------------
bool
ExeGetToolParam( const string& sName, int nType, int& nVal)
ExeTdbAddTool( const string& sName, int nType)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// recupero il parametro dell'utensile
return pGseCtx->m_pMachMgr->GetToolParam( sName, nType, nVal) ;
// aggiungo l'utensile
return pGseCtx->m_pMachMgr->TdbAddTool( sName, nType) ;
}
//-----------------------------------------------------------------------------
bool
ExeGetToolParam( const string& sName, int nType, double& dVal)
ExeTdbCopyTool( const string& sSource, const string& sName)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// recupero il parametro dell'utensile
return pGseCtx->m_pMachMgr->GetToolParam( sName, nType, dVal) ;
// copio l'utensile
return pGseCtx->m_pMachMgr->TdbCopyTool( sSource, sName) ;
}
//-----------------------------------------------------------------------------
bool
ExeGetToolParam( const string& sName, int nType, string& sVal)
ExeTdbRemoveTool( const string& sName)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// rimuovo l'utensile
return pGseCtx->m_pMachMgr->TdbRemoveTool( sName) ;
}
//----------------------------------------------------------------------------
bool
ExeTdbGetFirstTool( int nFamily, string& sName, int& nType)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// restituisce nome e tipo del primo utensile della famiglia
return pGseCtx->m_pMachMgr->TdbGetFirstTool( nFamily, sName, nType) ;
}
//----------------------------------------------------------------------------
bool
ExeTdbGetNextTool( int nFamily, string& sName, int& nType)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// restituisce nome e tipo del successivo utensile della famiglia
return pGseCtx->m_pMachMgr->TdbGetNextTool( nFamily, sName, nType) ;
}
//-----------------------------------------------------------------------------
bool
ExeTdbSetToolParam( const string& sName, int nType, int nVal)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// imposta il parametro dell'utensile
return pGseCtx->m_pMachMgr->TdbSetToolParam( sName, nType, nVal) ;
}
//-----------------------------------------------------------------------------
bool
ExeTdbSetToolParam( const string& sName, 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) ;
}
//-----------------------------------------------------------------------------
bool
ExeTdbSetToolParam( const string& sName, 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) ;
}
//-----------------------------------------------------------------------------
bool
ExeTdbGetToolParam( const string& sName, int nType, int& nVal)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// recupero il parametro dell'utensile
return pGseCtx->m_pMachMgr->GetToolParam( sName, nType, sVal) ;
return pGseCtx->m_pMachMgr->TdbGetToolParam( sName, nType, nVal) ;
}
//-----------------------------------------------------------------------------
bool
ExeTdbGetToolParam( const string& sName, 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) ;
}
//-----------------------------------------------------------------------------
bool
ExeTdbGetToolParam( const string& sName, 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) ;
}
//-----------------------------------------------------------------------------
bool
ExeTdbSave( void)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// eseguo il salvataggio del DB utensili
return pGseCtx->m_pMachMgr->TdbSave() ;
}
//-----------------------------------------------------------------------------
// Lavorazioni
//-----------------------------------------------------------------------------
int
ExeAddMachining( const string& sName, const std::string& sMachining)
@@ -842,6 +957,8 @@ ExeGetOperationType( int nId)
return pGseCtx->m_pMachMgr->GetOperationType( nId) ;
}
//-----------------------------------------------------------------------------
// Simulazione
//-----------------------------------------------------------------------------
bool
ExeSimStart( void)
@@ -862,6 +979,16 @@ ExeSimMove( void)
return pGseCtx->m_pMachMgr->SimMove() ;
}
//-----------------------------------------------------------------------------
bool
ExeSimHome( void)
{
GseContext* pGseCtx = GetCurrGseContext() ;
VERIFY_CTX_MACHMGR( pGseCtx, false)
// eseguo movimento di simulazione della macchinata corrente
return pGseCtx->m_pMachMgr->ResetAllAxesPos() ;
}
//-----------------------------------------------------------------------------
bool
ExeSimSetStep( double dStep)
BIN
View File
Binary file not shown.
+54 -1
View File
@@ -200,6 +200,56 @@ LuaOutBox( lua_State* L)
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaProcessEvents( lua_State* L)
{
// 2 parametri : nProg, nPause
int nProg ;
LuaCheckParam( L, 1, nProg)
int nPause ;
LuaCheckParam( L, 2, nPause)
LuaClearStack( L) ;
// lancio aggiornamento interfaccia
int nRes = ProcessEvents( nProg, nPause) ;
// restituisco il risultato
LuaSetParam( L, nRes) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaCopyFile( lua_State* L)
{
// 2 parametri : sFile, sNewFile
string sFile ;
LuaCheckParam( L, 1, sFile)
string sNewFile ;
LuaCheckParam( L, 2, sNewFile)
LuaClearStack( L) ;
// copio il file
bool bOk = CopyFileEgt( sFile, sNewFile) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaRenameFile( lua_State* L)
{
// 2 parametri : sFile, sNewFile
string sFile ;
LuaCheckParam( L, 1, sFile)
string sNewFile ;
LuaCheckParam( L, 2, sNewFile)
LuaClearStack( L) ;
// rinomino il file
bool bOk = RenameFile( sFile, sNewFile) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaEraseFile( lua_State* L)
@@ -208,7 +258,7 @@ LuaEraseFile( lua_State* L)
string sFile ;
LuaCheckParam( L, 1, sFile)
LuaClearStack( L) ;
// svuoto il direttorio
// cancello il file
bool bOk = EraseFile( sFile) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
@@ -326,6 +376,9 @@ LuaInstallGeneral( LuaMgr& luaMgr)
bOk = bOk && luaMgr.RegisterFunction( "EgtExecTsc", LuaExecTsc) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtOutLog", LuaOutLog) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtOutBox", LuaOutBox) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtProcessEvents", LuaProcessEvents) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtCopyFile", LuaCopyFile) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtRenameFile", LuaRenameFile) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtEraseFile", LuaEraseFile) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtEmptyDirectory", LuaEmptyDirectory) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtTextFileCompare", LuaTextFileCompare) ;
+188 -7
View File
@@ -22,6 +22,21 @@
using namespace std ;
//-------------------------------------------------------------------------------
static int
LuaSetCurrMachine( lua_State* L)
{
// 1 parametro : nome della macchina
string sMachineName ;
LuaCheckParam( L, 1, sMachineName)
LuaClearStack( L) ;
// rendo corrente la macchina
bool bOk = ExeSetCurrMachine( sMachineName) ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaGetMachGroupCount( lua_State* L)
@@ -73,11 +88,11 @@ LuaGetNextMachGroup( lua_State* L)
static int
LuaAddMachGroup( lua_State* L)
{
// 2 parametri : nome del gruppo, nome della macchina da utilizzare
// 1 o 2 parametri : nome del gruppo [, nome della macchina da utilizzare]
string sName ;
LuaCheckParam( L, 1, sName)
string sMachineName ;
LuaCheckParam( L, 2, sMachineName)
LuaGetParam( L, 2, sMachineName) ;
LuaClearStack( L) ;
// aggiungo la macchinata
int nId = ExeAddMachGroup( sName, sMachineName) ;
@@ -831,7 +846,135 @@ LuaVerifyOutOfStroke( lua_State* L)
//-------------------------------------------------------------------------------
static int
LuaGetToolParam( lua_State* L)
LuaTdbAddTool( lua_State* L)
{
// 2 parametri : sName, nType
string sName ;
LuaCheckParam( L, 1, sName)
int nType ;
LuaCheckParam( L, 2, nType)
LuaClearStack( L) ;
// aggiungo l'utensile
bool bOk = ExeTdbAddTool( sName, nType) ;
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaTdbCopyTool( lua_State* L)
{
// 2 parametri : sSource, sName
string sSource ;
LuaCheckParam( L, 1, sSource)
string sName ;
LuaCheckParam( L, 2, sName)
LuaClearStack( L) ;
// aggiungo l'utensile
bool bOk = ExeTdbCopyTool( sSource, sName) ;
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaTdbRemoveTool( lua_State* L)
{
// 1 parametro : sName
string sName ;
LuaCheckParam( L, 1, sName)
LuaClearStack( L) ;
// aggiungo l'utensile
bool bOk = ExeTdbRemoveTool( sName) ;
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaTdbGetFirstTool( lua_State* L)
{
// 1 parametro : nFamily
int nFamily ;
LuaCheckParam( L, 1, nFamily)
// cerco il primo utensile della famiglia
string sName ;
int nType ;
bool bOk = ExeTdbGetFirstTool( nFamily, sName, nType) ;
// restituisco il risultato
if ( bOk) {
LuaSetParam( L, sName) ;
LuaSetParam( L, nType) ;
}
else {
LuaSetParam( L, "") ;
LuaSetParam( L, TT_NONE) ;
}
return 2 ;
}
//-------------------------------------------------------------------------------
static int
LuaTdbGetNextTool( lua_State* L)
{
// 1 parametro : nFamily
int nFamily ;
LuaCheckParam( L, 1, nFamily)
// cerco il prossimo utensile della famiglia
string sName ;
int nType ;
bool bOk = ExeTdbGetNextTool( nFamily, sName, nType) ;
// restituisco il risultato
if ( bOk) {
LuaSetParam( L, sName) ;
LuaSetParam( L, nType) ;
}
else {
LuaSetParam( L, "") ;
LuaSetParam( L, TT_NONE) ;
}
return 2 ;
}
//-------------------------------------------------------------------------------
static int
LuaTdbSetToolParam( lua_State* L)
{
// 3 parametri : sName, nType, Val
string sName ;
LuaCheckParam( L, 1, sName)
int nType ;
LuaCheckParam( L, 2, nType)
// leggo opportunamente il valore da assegnare
if ( ( nType & TPA_INT) != 0) {
int nVal ;
LuaCheckParam( L, 3, nVal)
LuaClearStack( L) ;
bool bOk = ExeTdbSetToolParam( sName, nType, nVal) ;
LuaSetParam( L, bOk) ;
}
else if ( ( nType & TPA_DOU) != 0) {
double dVal ;
LuaCheckParam( L, 3, dVal)
LuaClearStack( L) ;
bool bOk = ExeTdbSetToolParam( sName, nType, dVal) ;
LuaSetParam( L, bOk) ;
}
else if ( ( nType & TPA_STR) != 0) {
string sVal ;
LuaCheckParam( L, 3, sVal)
LuaClearStack( L) ;
bool bOk = ExeTdbSetToolParam( sName, nType, sVal) ;
LuaSetParam( L, bOk) ;
}
else
LuaSetParam( L, false) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaTdbGetToolParam( lua_State* L)
{
// 2 parametri : sName, nType
string sName ;
@@ -842,7 +985,7 @@ LuaGetToolParam( lua_State* L)
// recupero il parametro dell'utensile voluto
if ( ( nType & TPA_INT) != 0) {
int nVal ;
bool bOk = ExeGetToolParam( sName, nType, nVal) ;
bool bOk = ExeTdbGetToolParam( sName, nType, nVal) ;
if ( bOk)
LuaSetParam( L, nVal) ;
else
@@ -850,7 +993,7 @@ LuaGetToolParam( lua_State* L)
}
else if ( ( nType & TPA_DOU) != 0) {
double dVal ;
bool bOk = ExeGetToolParam( sName, nType, dVal) ;
bool bOk = ExeTdbGetToolParam( sName, nType, dVal) ;
if ( bOk)
LuaSetParam( L, dVal) ;
else
@@ -858,7 +1001,7 @@ LuaGetToolParam( lua_State* L)
}
else if ( ( nType & TPA_STR) != 0) {
string sVal ;
bool bOk = ExeGetToolParam( sName, nType, sVal) ;
bool bOk = ExeTdbGetToolParam( sName, nType, sVal) ;
if ( bOk)
LuaSetParam( L, sVal) ;
else
@@ -869,6 +1012,18 @@ LuaGetToolParam( lua_State* L)
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaTdbSave( lua_State* L)
{
// nessun parametro
LuaClearStack( L) ;
// lancio salvataggio
bool bOk = ExeTdbSave() ;
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaAddMachining( lua_State* L)
@@ -1030,6 +1185,19 @@ LuaSimMove( lua_State* L)
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaSimHome( lua_State* L)
{
// nessun parametro
LuaClearStack( L) ;
// porto la macchina in posizione home
bool bOk = ExeSimHome() ;
// restituisco il risultato
LuaSetParam( L, bOk) ;
return 1 ;
}
//-------------------------------------------------------------------------------
static int
LuaSimSetStep( lua_State* L)
@@ -1063,6 +1231,7 @@ bool
LuaInstallMachMgr( LuaMgr& luaMgr)
{
bool bOk = ( &luaMgr != nullptr) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSetCurrMachine", LuaSetCurrMachine) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetMachGroupCount", LuaGetMachGroupCount) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetFirstMachGroup", LuaGetFirstMachGroup) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetNextMachGroup", LuaGetNextMachGroup) ;
@@ -1092,9 +1261,11 @@ LuaInstallMachMgr( LuaMgr& luaMgr)
bOk = bOk && luaMgr.RegisterFunction( "EgtRemovePartFromRawPart", LuaRemovePartFromRawPart) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtMovePartInRawPart", LuaTranslatePartInRawPart) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtRotatePartInRawPart", LuaRotatePartInRawPart) ;
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) ;
@@ -1107,7 +1278,16 @@ LuaInstallMachMgr( LuaMgr& luaMgr)
bOk = bOk && luaMgr.RegisterFunction( "EgtGetCalcAngles", LuaGetCalcAngles) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetCalcPositions", LuaGetCalcPositions) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtVerifyOutOfStroke", LuaVerifyOutOfStroke) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtGetToolParam", LuaGetToolParam) ;
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( "EgtAddMachining", LuaAddMachining) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSetMachiningParam", LuaSetMachiningParam) ;
bOk = bOk && luaMgr.RegisterFunction( "EgtSetMachiningGeometry", LuaSetMachiningGeometry) ;
@@ -1117,6 +1297,7 @@ LuaInstallMachMgr( LuaMgr& luaMgr)
bOk = bOk && luaMgr.RegisterFunction( "EgtGetOperationType", LuaGetOperationType) ;
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) ;