d7c8a61456
- modifiche varie per OmagCut.
1014 lines
30 KiB
C++
1014 lines
30 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2015-2015
|
|
//----------------------------------------------------------------------------
|
|
// File : LUA_MachMgr.cpp Data : 24.03.15 Versione : 1.6c8
|
|
// Contenuto : Funzioni Machining Manager per LUA.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 24.03.15 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "LUA.h"
|
|
#include "/EgtDev/Include/EXeExecutor.h"
|
|
#include "/EgtDev/Include/EMkToolConst.h"
|
|
#include "/EgtDev/Include/EMkMachiningConst.h"
|
|
#include "/EgtDev/Include/EGkGdbConst.h"
|
|
#include "/EgtDev/Include/EGkLuaAux.h"
|
|
|
|
using namespace std ;
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaGetMachGroupCount( lua_State* L)
|
|
{
|
|
// nessun parametro
|
|
LuaClearStack( L) ;
|
|
// recupero il numero di macchinate
|
|
int nTot = ExeGetMachGroupCount() ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, nTot) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaGetFirstMachGroup( lua_State* L)
|
|
{
|
|
// nessun parametro
|
|
LuaClearStack( L) ;
|
|
// recupero l'identificativo della prima macchinata
|
|
int nId = ExeGetFirstMachGroup() ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaGetNextMachGroup( lua_State* L)
|
|
{
|
|
// 1 parametro : identificativo di una macchinata
|
|
int nId ;
|
|
LuaCheckParam( L, 1, nId)
|
|
LuaClearStack( L) ;
|
|
// recupero l'identificativo della successiva macchinata
|
|
int nNextId = ExeGetNextMachGroup( nId) ;
|
|
// restituisco il risultato
|
|
if ( nNextId != GDB_ID_NULL)
|
|
LuaSetParam( L, nNextId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaAddMachGroup( lua_State* L)
|
|
{
|
|
// 2 parametri : nome del gruppo, nome della macchina da utilizzare
|
|
string sName ;
|
|
LuaCheckParam( L, 1, sName)
|
|
string sMachineName ;
|
|
LuaCheckParam( L, 2, sMachineName)
|
|
LuaClearStack( L) ;
|
|
// aggiungo la macchinata
|
|
int nId = ExeAddMachGroup( sName, sMachineName) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaRemoveMachGroup( lua_State* L)
|
|
{
|
|
// 1 parametro : identificativo del gruppo
|
|
int nMGroupInd ;
|
|
LuaCheckParam( L, 1, nMGroupInd)
|
|
LuaClearStack( L) ;
|
|
// rimuovo la macchinata
|
|
bool bOk = ExeRemoveMachGroup( nMGroupInd) ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaGetMachGroupName( lua_State* L)
|
|
{
|
|
// 1 parametro : identificativo del gruppo
|
|
int nMGroupInd ;
|
|
LuaCheckParam( L, 1, nMGroupInd)
|
|
LuaClearStack( L) ;
|
|
// recupero il nome della macchinata
|
|
string sName ;
|
|
bool bOk = ExeGetMachGroupName( nMGroupInd, sName) ;
|
|
// restituisco il risultato
|
|
if ( bOk)
|
|
LuaSetParam( L, sName) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaGetMachGroupId( lua_State* L)
|
|
{
|
|
// 1 parametro : nome del gruppo
|
|
string sGroupName ;
|
|
LuaCheckParam( L, 1, sGroupName)
|
|
LuaClearStack( L) ;
|
|
// recupero l'identificativo della macchinata
|
|
int nId = ExeGetMachGroupId( sGroupName) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaSetCurrMachGroup( lua_State* L)
|
|
{
|
|
// 1 parametro : identificativo del gruppo
|
|
int nMGroupInd ;
|
|
LuaCheckParam( L, 1, nMGroupInd)
|
|
LuaClearStack( L) ;
|
|
// imposto il gruppo corrente
|
|
bool bOk = ExeSetCurrMachGroup( nMGroupInd) ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaResetCurrMachGroup( lua_State* L)
|
|
{
|
|
// nessun parametro
|
|
LuaClearStack( L) ;
|
|
// imposto il gruppo corrente
|
|
bool bOk = ExeResetCurrMachGroup() ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaGetCurrMachGroup( lua_State* L)
|
|
{
|
|
// nessun parametro
|
|
LuaClearStack( L) ;
|
|
// recupero l'identificativo del gruppo corrente
|
|
int nId = ExeGetCurrMachGroup() ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaGetRawPartCount( lua_State* L)
|
|
{
|
|
// nessun parametro
|
|
LuaClearStack( L) ;
|
|
// recupero il numero di grezzi nella macchinata corrente
|
|
int nCount = ExeGetRawPartCount() ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, nCount) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaGetFirstRawPart( lua_State* L)
|
|
{
|
|
// nessun parametro
|
|
LuaClearStack( L) ;
|
|
// recupero identificativo primo grezzo nella macchinata corrente
|
|
int nId = ExeGetFirstRawPart() ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaGetNextRawPart( lua_State* L)
|
|
{
|
|
// 1 parametro : nRawId
|
|
int nRawId ;
|
|
LuaCheckParam( L, 1, nRawId)
|
|
LuaClearStack( L) ;
|
|
// recupero identificativo successivo grezzo nella macchinata corrente
|
|
int nId = ExeGetNextRawPart( nRawId) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaAddRawPart( lua_State* L)
|
|
{
|
|
// 5 parametri : Pto origine, dLen, dWidth, dH, Color
|
|
Point3d ptOrig ;
|
|
LuaCheckParam( L, 1, ptOrig)
|
|
double dLength ;
|
|
LuaCheckParam( L, 2, dLength)
|
|
double dWidth ;
|
|
LuaCheckParam( L, 3, dWidth)
|
|
double dHeight ;
|
|
LuaCheckParam( L, 4, dHeight)
|
|
Color cCol ;
|
|
LuaCheckParam( L, 5, cCol)
|
|
LuaClearStack( L) ;
|
|
// inserisco il grezzo nella macchinata corrente
|
|
int nInd = ExeAddRawPart( ptOrig, dLength, dWidth, dHeight, cCol) ;
|
|
// restituisco il risultato
|
|
if ( nInd != GDB_ID_NULL)
|
|
LuaSetParam( L, nInd) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaAddRawPartWithPart( lua_State* L)
|
|
{
|
|
// 4 parametri : nPartId, nCrvId, dOverMat, Color
|
|
int nPartId ;
|
|
LuaCheckParam( L, 1, nPartId)
|
|
int nCrvId = GDB_ID_NULL ;
|
|
LuaGetParam( L, 2, nCrvId) ;
|
|
double dOverMat ;
|
|
LuaCheckParam( L, 3, dOverMat)
|
|
Color cCol ;
|
|
LuaCheckParam( L, 4, cCol)
|
|
LuaClearStack( L) ;
|
|
// inserisco il grezzo nella macchinata corrente
|
|
int nInd = ExeAddRawPartWithPart( nPartId, nCrvId, dOverMat, cCol) ;
|
|
// restituisco il risultato
|
|
if ( nInd != GDB_ID_NULL)
|
|
LuaSetParam( L, nInd) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaModifyRawPartSize( lua_State* L)
|
|
{
|
|
// 4 parametri : nRawId, dLength, dWidth, dHeight
|
|
int nRawId ;
|
|
LuaCheckParam( L, 1, nRawId)
|
|
double dLength ;
|
|
LuaCheckParam( L, 2, dLength)
|
|
double dWidth ;
|
|
LuaCheckParam( L, 3, dWidth)
|
|
double dHeight ;
|
|
LuaCheckParam( L, 4, dHeight)
|
|
LuaClearStack( L) ;
|
|
// modifico le dimensioni del grezzo
|
|
bool bOk = ExeModifyRawPartSize( nRawId, dLength, dWidth, dHeight) ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaModifyRawPartHeight( lua_State* L)
|
|
{
|
|
// 2 parametri : nRawId, dHeight
|
|
int nRawId ;
|
|
LuaCheckParam( L, 1, nRawId)
|
|
double dHeight ;
|
|
LuaCheckParam( L, 2, dHeight)
|
|
LuaClearStack( L) ;
|
|
// modifico lo spessore del grezzo
|
|
bool bOk = ExeModifyRawPartHeight( nRawId, dHeight) ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaRemoveRawPart( lua_State* L)
|
|
{
|
|
// 1 parametro : nRawId
|
|
int nRawId ;
|
|
LuaCheckParam( L, 1, nRawId)
|
|
LuaClearStack( L) ;
|
|
// elimino il grezzo dalla macchinata corrente
|
|
bool bOk = ExeRemoveRawPart( nRawId) ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaMoveRawPart( lua_State* L)
|
|
{
|
|
// 2 parametri : nRawId, vtMove
|
|
int nRawId ;
|
|
LuaCheckParam( L, 1, nRawId)
|
|
Vector3d vtMove ;
|
|
LuaCheckParam( L, 2, vtMove)
|
|
LuaClearStack( L) ;
|
|
// traslo il grezzo
|
|
bool bOk = ExeMoveRawPart( nRawId, vtMove) ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaRotateRawPart( lua_State* L)
|
|
{
|
|
// 3 parametri : nRawId, vtAx, dAngRotDeg
|
|
int nRawId ;
|
|
LuaCheckParam( L, 1, nRawId)
|
|
Vector3d vtAx ;
|
|
LuaCheckParam( L, 2, vtAx)
|
|
double dAngRotDeg ;
|
|
LuaCheckParam( L, 3, dAngRotDeg)
|
|
LuaClearStack( L) ;
|
|
// ruoto il grezzo
|
|
bool bOk = ExeRotateRawPart( nRawId, vtAx, dAngRotDeg) ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaMoveToCornerRawPart( lua_State* L)
|
|
{
|
|
// 3 parametri : nRawId, ptCorner, nFlag
|
|
int nRawId ;
|
|
LuaCheckParam( L, 1, nRawId)
|
|
Point3d ptCorner ;
|
|
LuaCheckParam( L, 2, ptCorner)
|
|
int nFlag ;
|
|
LuaCheckParam( L, 3, nFlag)
|
|
LuaClearStack( L) ;
|
|
// sposto il grezzo nel corner
|
|
bool bOk = ExeMoveToCornerRawPart( nRawId, ptCorner, nFlag) ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaMoveToCenterRawPart( lua_State* L)
|
|
{
|
|
// 3 parametri : nRawId, ptCenter, nFlag
|
|
int nRawId ;
|
|
LuaCheckParam( L, 1, nRawId)
|
|
Point3d ptCenter ;
|
|
LuaCheckParam( L, 2, ptCenter)
|
|
int nFlag ;
|
|
LuaCheckParam( L, 3, nFlag)
|
|
LuaClearStack( L) ;
|
|
// sposto il grezzo nel corner
|
|
bool bOk = ExeMoveToCenterRawPart( nRawId, ptCenter, nFlag) ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaGetPartInRawPartCount( lua_State* L)
|
|
{
|
|
// 1 parametro : nRawId
|
|
int nRawId ;
|
|
LuaCheckParam( L, 1, nRawId)
|
|
LuaClearStack( L) ;
|
|
// recupero il numero di pezzi nel grezzo
|
|
int nCount = ExeGetPartInRawPartCount( nRawId) ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, nCount) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaGetFirstPartInRawPart( lua_State* L)
|
|
{
|
|
// 1 parametro : nRawId
|
|
int nRawId ;
|
|
LuaCheckParam( L, 1, nRawId)
|
|
LuaClearStack( L) ;
|
|
// recupero identificativo primo pezzo nel grezzo
|
|
int nId = ExeGetFirstPartInRawPart( nRawId) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaGetNextPartInRawPart( lua_State* L)
|
|
{
|
|
// 1 parametro : nPartId
|
|
int nPartId ;
|
|
LuaCheckParam( L, 1, nPartId)
|
|
LuaClearStack( L) ;
|
|
// recupero identificativo successivo pezzo nello stesso grezzo
|
|
int nId = ExeGetNextPartInRawPart( nPartId) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaAddPartToRawPart( lua_State* L)
|
|
{
|
|
// 3 parametri : nPartId, ptPos, nRawId
|
|
int nPartId ;
|
|
LuaCheckParam( L, 1, nPartId)
|
|
Point3d ptPos ;
|
|
LuaCheckParam( L, 2, ptPos)
|
|
int nRawId ;
|
|
LuaCheckParam( L, 3, nRawId)
|
|
LuaClearStack( L) ;
|
|
// inserisco il grezzo nella macchinata corrente
|
|
bool bOk = ExeAddPartToRawPart( nPartId, ptPos, nRawId) ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaRemovePartFromRawPart( lua_State* L)
|
|
{
|
|
// 1 parametro : nPartId
|
|
int nPartId ;
|
|
LuaCheckParam( L, 1, nPartId)
|
|
LuaClearStack( L) ;
|
|
// elimino il grezzo dalla macchinata corrente
|
|
bool bOk = ExeRemovePartFromRawPart( nPartId) ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaTranslatePartInRawPart( lua_State* L)
|
|
{
|
|
// 2 parametri : nPartId, vtMove
|
|
int nPartId ;
|
|
LuaCheckParam( L, 1, nPartId)
|
|
Vector3d vtMove ;
|
|
LuaCheckParam( L, 2, vtMove)
|
|
LuaClearStack( L) ;
|
|
// traslo il pezzo nel grezzo
|
|
bool bOk = ExeTranslatePartInRawPart( nPartId, vtMove) ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaRotatePartInRawPart( lua_State* L)
|
|
{
|
|
// 3 parametri : nPartId, vtAx, dAngRotDeg
|
|
int nPartId ;
|
|
LuaCheckParam( L, 1, nPartId)
|
|
Vector3d vtAx ;
|
|
LuaCheckParam( L, 2, vtAx)
|
|
double dAngRotDeg ;
|
|
LuaCheckParam( L, 3, dAngRotDeg)
|
|
LuaClearStack( L) ;
|
|
// ruoto il pezzo nel grezzo
|
|
bool bOk = ExeRotatePartInRawPart( nPartId, vtAx, dAngRotDeg) ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaSetTable( lua_State* L)
|
|
{
|
|
// 1 parametro : sTable
|
|
string sTable ;
|
|
LuaCheckParam( L, 1, sTable)
|
|
LuaClearStack( L) ;
|
|
// imposto la tavola corrente
|
|
bool bOk = ExeSetTable( sTable) ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaGetTableRef1( lua_State* L)
|
|
{
|
|
// nessun parametro
|
|
LuaClearStack( L) ;
|
|
// imposto la tavola corrente
|
|
Point3d ptPos ;
|
|
bool bOk = ExeGetTableRef1( ptPos) ;
|
|
// restituisco il risultato
|
|
if ( bOk)
|
|
LuaSetParam( L, ptPos) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaAddSubPiece( lua_State* L)
|
|
{
|
|
// 2 o 3 parametri : sName, ptPos [, dAngRotDeg]
|
|
string sName ;
|
|
LuaCheckParam( L, 1, sName)
|
|
Point3d ptPos ;
|
|
LuaCheckParam( L, 2, ptPos)
|
|
double dAngRotDeg = 0 ;
|
|
LuaGetParam( L, 3, dAngRotDeg) ;
|
|
LuaClearStack( L) ;
|
|
// metto l'asse nella nuova posizione
|
|
int nId = ExeAddSubPiece( sName, ptPos, dAngRotDeg) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
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 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
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
|
|
LuaGetToolParam( lua_State* L)
|
|
{
|
|
// 2 parametri : sName, nType
|
|
string sName ;
|
|
LuaCheckParam( L, 1, sName)
|
|
int nType ;
|
|
LuaCheckParam( L, 2, nType)
|
|
LuaClearStack( L) ;
|
|
// recupero il parametro dell'utensile voluto
|
|
if ( ( nType & TPA_INT) != 0) {
|
|
int nVal ;
|
|
bool bOk = ExeGetToolParam( sName, nType, nVal) ;
|
|
if ( bOk)
|
|
LuaSetParam( L, nVal) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
}
|
|
else if ( ( nType & TPA_DOU) != 0) {
|
|
double dVal ;
|
|
bool bOk = ExeGetToolParam( sName, nType, dVal) ;
|
|
if ( bOk)
|
|
LuaSetParam( L, dVal) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
}
|
|
else if ( ( nType & TPA_STR) != 0) {
|
|
string sVal ;
|
|
bool bOk = ExeGetToolParam( sName, nType, sVal) ;
|
|
if ( bOk)
|
|
LuaSetParam( L, sVal) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
}
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaAddMachining( lua_State* L)
|
|
{
|
|
// 2 parametri : sName, sMachining
|
|
string sName ;
|
|
LuaCheckParam( L, 1, sName)
|
|
string sMachining ;
|
|
LuaCheckParam( L, 2, sMachining)
|
|
LuaClearStack( L) ;
|
|
// aggiungo la lavorazione
|
|
int nId = ExeAddMachining( sName, sMachining) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetParam( L, nId) ;
|
|
else
|
|
LuaSetParam( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaSetMachiningParam( lua_State* L)
|
|
{
|
|
// 2 parametri : nType, xVal
|
|
int nType ;
|
|
LuaCheckParam( L, 1, nType)
|
|
bool bOk = false ;
|
|
if ( ( nType & MPA_BOOL) != 0) {
|
|
bool bVal ;
|
|
LuaCheckParam( L, 2, bVal)
|
|
// imposto il parametro alla lavorazione corrente
|
|
bOk = ExeSetMachiningParam( nType, bVal) ;
|
|
}
|
|
else if ( ( nType & MPA_INT) != 0) {
|
|
int nVal ;
|
|
LuaCheckParam( L, 2, nVal)
|
|
// imposto il parametro alla lavorazione corrente
|
|
bOk = ExeSetMachiningParam( nType, nVal) ;
|
|
}
|
|
else if ( ( nType & MPA_DOU) != 0) {
|
|
double dVal ;
|
|
LuaCheckParam( L, 2, dVal)
|
|
// imposto il parametro alla lavorazione corrente
|
|
bOk = ExeSetMachiningParam( nType, dVal) ;
|
|
}
|
|
else if ( ( nType & MPA_STR) != 0) {
|
|
string sVal ;
|
|
LuaCheckParam( L, 2, sVal)
|
|
// imposto il parametro alla lavorazione corrente
|
|
bOk = ExeSetMachiningParam( nType, sVal) ;
|
|
}
|
|
LuaClearStack( L) ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaSetMachiningGeometry( lua_State* L)
|
|
{
|
|
// 1 parametro : vSel
|
|
SELVECTOR vSel ;
|
|
LuaCheckParam( L, 1, vSel)
|
|
LuaClearStack( L) ;
|
|
// imposto la geometria alla lavorazione corrente
|
|
bool bOk = ExeSetMachiningGeometry( vSel) ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaApplyMachining( lua_State* L)
|
|
{
|
|
// nessun parametro
|
|
LuaClearStack( L) ;
|
|
// imposto la geometria alla lavorazione corrente
|
|
bool bOk = ExeApplyMachining() ;
|
|
// restituisco il risultato
|
|
LuaSetParam( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
bool
|
|
LuaInstallMachMgr( LuaMgr& luaMgr)
|
|
{
|
|
bool bOk = ( &luaMgr != nullptr) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtGetMachGroupCount", LuaGetMachGroupCount) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtGetFirstMachGroup", LuaGetFirstMachGroup) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtGetNextMachGroup", LuaGetNextMachGroup) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtAddMachGroup", LuaAddMachGroup) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtRemoveMachGroup", LuaRemoveMachGroup) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtGetMachGroupName", LuaGetMachGroupName) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtGetMachGroupId", LuaGetMachGroupId) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSetCurrMachGroup", LuaSetCurrMachGroup) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtResetCurrMachGroup", LuaResetCurrMachGroup) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtGetCurrMachGroup", LuaGetCurrMachGroup) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtGetRawPartCount", LuaGetRawPartCount) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtGetFirstRawPart", LuaGetFirstRawPart) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtGetNextRawPart", LuaGetNextRawPart) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtAddRawPart", LuaAddRawPart) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtAddRawPartWithPart", LuaAddRawPartWithPart) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtModifyRawPartSize", LuaModifyRawPartSize) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtModifyRawPartHeight", LuaModifyRawPartHeight) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtRemoveRawPart", LuaRemoveRawPart) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtRotateRawPart", LuaRotateRawPart) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtMoveToCornerRawPart", LuaMoveToCornerRawPart) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtMoveToCenterRawPart", LuaMoveToCenterRawPart) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtMoveRawPart", LuaMoveRawPart) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtGetPartInRawPartCount", LuaGetPartInRawPartCount) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtGetFirstPartInRawPart", LuaGetFirstPartInRawPart) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtGetNextPartInRawPart", LuaGetNextPartInRawPart) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtAddPartToRawPart", LuaAddPartToRawPart) ;
|
|
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) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtResetAxisPos", LuaResetAxisPos) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtLoadTool", LuaLoadTool) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtResetHeadSet", LuaResetHeadSet) ;
|
|
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( "EgtGetToolParam", LuaGetToolParam) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtAddMachining", LuaAddMachining) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSetMachiningParam", LuaSetMachiningParam) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtSetMachiningGeometry", LuaSetMachiningGeometry) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtApplyMachining", LuaApplyMachining) ;
|
|
|
|
return bOk ;
|
|
}
|