966885645e
- primo rilascio (esecutore e lua da EgtInterface).
542 lines
16 KiB
C++
542 lines
16 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
|
|
LuaSetReturn( L, nId) ;
|
|
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 ;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
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) ;
|
|
|
|
return bOk ;
|
|
}
|