785c9add4b
- aggiustamenti vari per macchina e lavorazioni.
824 lines
24 KiB
C++
824 lines
24 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/EGkGdbConst.h"
|
|
#include "/EgtDev/Include/EGkLuaAux.h"
|
|
|
|
using namespace std ;
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaGetMachGroupNbr( lua_State* L)
|
|
{
|
|
// nessun parametro
|
|
LuaClearStack( L) ;
|
|
// recupero il numero di macchinate
|
|
int nTot = ExeGetMachGroupNbr() ;
|
|
// restituisco il risultato
|
|
LuaSetReturn( 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)
|
|
LuaSetReturn( L, nId) ;
|
|
else
|
|
LuaSetReturn( 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)
|
|
LuaSetReturn( L, nNextId) ;
|
|
else
|
|
LuaSetReturn( 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)
|
|
LuaSetReturn( L, nId) ;
|
|
else
|
|
LuaSetReturn( 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
|
|
LuaSetReturn( 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)
|
|
LuaSetReturn( L, sName) ;
|
|
else
|
|
LuaSetReturn( 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)
|
|
LuaSetReturn( L, nId) ;
|
|
else
|
|
LuaSetReturn( 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
|
|
LuaSetReturn( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaResetCurrMachGroup( lua_State* L)
|
|
{
|
|
// nessun parametro
|
|
LuaClearStack( L) ;
|
|
// imposto il gruppo corrente
|
|
bool bOk = ExeResetCurrMachGroup() ;
|
|
// restituisco il risultato
|
|
LuaSetReturn( 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)
|
|
LuaSetReturn( L, nId) ;
|
|
else
|
|
LuaSetReturn( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaGetRawPartNbr( lua_State* L)
|
|
{
|
|
// nessun parametro
|
|
LuaClearStack( L) ;
|
|
// recupero il numero di grezzi nella macchinata corrente
|
|
int nCount = ExeGetRawPartNbr() ;
|
|
// restituisco il risultato
|
|
LuaSetReturn( 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)
|
|
LuaSetReturn( L, nId) ;
|
|
else
|
|
LuaSetReturn( 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)
|
|
LuaSetReturn( L, nId) ;
|
|
else
|
|
LuaSetReturn( L) ;
|
|
return 1 ;
|
|
}
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaAddRawPart( lua_State* L)
|
|
{
|
|
// 5 parametri : Pto origine, dWidth, dLen, dH, Color
|
|
Point3d ptOrig ;
|
|
LuaCheckParam( L, 1, ptOrig)
|
|
double dWidth ;
|
|
LuaCheckParam( L, 2, dWidth)
|
|
double dLength ;
|
|
LuaCheckParam( L, 3, dLength)
|
|
double dHeight ;
|
|
LuaCheckParam( L, 4, dHeight)
|
|
Color cCol ;
|
|
LuaCheckParam( L, 5, cCol)
|
|
LuaClearStack( L) ;
|
|
// inserisco il grezzo nella macchinata corrente
|
|
int nInd = ExeAddRawPart( ptOrig, dWidth, dLength, dHeight, cCol) ;
|
|
// restituisco il risultato
|
|
if ( nInd != GDB_ID_NULL)
|
|
LuaSetReturn( L, nInd) ;
|
|
else
|
|
LuaSetReturn( 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)
|
|
LuaSetReturn( L, nInd) ;
|
|
else
|
|
LuaSetReturn( L) ;
|
|
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
|
|
LuaSetReturn( 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
|
|
LuaSetReturn( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaTranslateRawPart( 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 = ExeTranslateRawPart( nRawId, vtMove) ;
|
|
// restituisco il risultato
|
|
LuaSetReturn( 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
|
|
LuaSetReturn( 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
|
|
LuaSetReturn( 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
|
|
LuaSetReturn( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaGetPartInRawPartNbr( lua_State* L)
|
|
{
|
|
// 1 parametro : nRawId
|
|
int nRawId ;
|
|
LuaCheckParam( L, 1, nRawId)
|
|
LuaClearStack( L) ;
|
|
// recupero il numero di pezzi nel grezzo
|
|
int nCount = ExeGetPartInRawPartNbr( nRawId) ;
|
|
// restituisco il risultato
|
|
LuaSetReturn( 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)
|
|
LuaSetReturn( L, nId) ;
|
|
else
|
|
LuaSetReturn( 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)
|
|
LuaSetReturn( L, nId) ;
|
|
else
|
|
LuaSetReturn( 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
|
|
LuaSetReturn( 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
|
|
LuaSetReturn( 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
|
|
LuaSetReturn( 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
|
|
LuaSetReturn( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaAddSubPiece( lua_State* L)
|
|
{
|
|
// 2 parametri : sName, ptPos
|
|
string sName ;
|
|
LuaCheckParam( L, 1, sName)
|
|
Point3d ptPos ;
|
|
LuaCheckParam( L, 2, ptPos)
|
|
LuaClearStack( L) ;
|
|
// metto l'asse nella nuova posizione
|
|
int nId = ExeAddSubPiece( sName, ptPos) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetReturn( L, nId) ;
|
|
else
|
|
LuaSetReturn( 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
|
|
LuaSetReturn( 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)
|
|
LuaSetReturn( L, dVal) ;
|
|
else
|
|
LuaSetReturn( 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)
|
|
LuaSetReturn( L, dHomeVal) ;
|
|
else
|
|
LuaSetReturn( 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
|
|
LuaSetReturn( 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
|
|
LuaSetReturn( 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
|
|
LuaSetReturn( 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 il calcolo
|
|
bool bOk = ExeSetCalcTable( sTable) ;
|
|
// restituisco il risultato
|
|
LuaSetReturn( 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 la tavola corrente per il calcolo
|
|
bool bOk = ExeSetCalcTool( sTool, sHead, nExit) ;
|
|
// restituisco il risultato
|
|
LuaSetReturn( L, bOk) ;
|
|
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) {
|
|
LuaSetReturn( L, bOk) ;
|
|
LuaSetReturn( L, nStat) ;
|
|
LuaSetReturn( L, dAngA1) ;
|
|
LuaSetReturn( L, dAngB1) ;
|
|
LuaSetReturn( L, dAngA2) ;
|
|
LuaSetReturn( L, dAngB2) ;
|
|
return 6 ;
|
|
}
|
|
else {
|
|
LuaSetReturn( 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) {
|
|
LuaSetReturn( L, bOk) ;
|
|
LuaSetReturn( L, nStat) ;
|
|
LuaSetReturn( L, dX) ;
|
|
LuaSetReturn( L, dY) ;
|
|
LuaSetReturn( L, dZ) ;
|
|
return 5 ;
|
|
}
|
|
else {
|
|
LuaSetReturn( 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) {
|
|
LuaSetReturn( L, bOk) ;
|
|
LuaSetReturn( L, nStat) ;
|
|
return 2 ;
|
|
}
|
|
else {
|
|
LuaSetReturn( L, bOk) ;
|
|
return 1 ;
|
|
}
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
static int
|
|
LuaAddDrilling( lua_State* L)
|
|
{
|
|
// 1 parametro : sName
|
|
string sName ;
|
|
LuaCheckParam( L, 1, sName)
|
|
LuaClearStack( L) ;
|
|
// aggiungo la lavorazione
|
|
int nId = ExeAddDrilling( sName) ;
|
|
// restituisco il risultato
|
|
if ( nId != GDB_ID_NULL)
|
|
LuaSetReturn( L, nId) ;
|
|
else
|
|
LuaSetReturn( L) ;
|
|
return 1 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
bool
|
|
LuaInstallMachMgr( LuaMgr& luaMgr)
|
|
{
|
|
bool bOk = ( &luaMgr != nullptr) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtGetMachGroupNbr", LuaGetMachGroupNbr) ;
|
|
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( "EgtGetRawPartNbr", LuaGetRawPartNbr) ;
|
|
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( "EgtModifyRawPartHeight", LuaModifyRawPartHeight) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtRemoveRawPart", LuaRemoveRawPart) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtMoveRawPart", LuaTranslateRawPart) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtRotateRawPart", LuaRotateRawPart) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtMoveToCornerRawPart", LuaMoveToCornerRawPart) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtMoveToCenterRawPart", LuaMoveToCenterRawPart) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtGetPartInRawPartNbr", LuaGetPartInRawPartNbr) ;
|
|
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( "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( "EgtGetCalcAngles", LuaGetCalcAngles) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtGetCalcPositions", LuaGetCalcPositions) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtVerifyOutOfStroke", LuaVerifyOutOfStroke) ;
|
|
bOk = bOk && luaMgr.RegisterFunction( "EgtAddDrilling", LuaAddDrilling) ;
|
|
|
|
return bOk ;
|
|
}
|