785c9add4b
- aggiustamenti vari per macchina e lavorazioni.
652 lines
24 KiB
C++
652 lines
24 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2015-2015
|
|
//----------------------------------------------------------------------------
|
|
// File : EXE_MachMgr.cpp Data : 05.05.15 Versione : 1.6e1
|
|
// Contenuto : Funzioni Machining Manager per EXE.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 23.03.15 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "EXE.h"
|
|
#include "EXE_Macro.h"
|
|
#include "Lua_Base.h"
|
|
#include "AuxTools.h"
|
|
#include "DllMachKernel.h"
|
|
#include "/EgtDev/Include/EXeExecutor.h"
|
|
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
|
#include "/EgtDev/Include/EgtStringConverter.h"
|
|
#include "/EgtDev/Include/EgtPointerOwner.h"
|
|
|
|
using namespace std ;
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeInitMachMgr( const string& sMachinesDir)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_GEOMDB( pGseCtx, false)
|
|
// inizializzazione gestore lavorazioni
|
|
PtrOwner<IMachMgr> pMachMgr( MyCreateMachMgr()) ;
|
|
VERIFY_NULL( Get( pMachMgr), "Error in CreateMachMgr", false)
|
|
bool bOk = pMachMgr->Init( sMachinesDir, pGseCtx->m_pGeomDB,
|
|
GetIndCurrGseContext(), LuaGetLuaLibsDir(), LuaGetLastRequire()) ;
|
|
// assegno il gestore al contesto
|
|
pGseCtx->m_pMachMgr = ( bOk ? Release( pMachMgr) : nullptr) ;
|
|
// log avvio Machining Manager
|
|
string sLog = "MachMgr" ;
|
|
sLog += ( bOk ? " started" : " error") ;
|
|
sLog += " (" + sMachinesDir + ")" ;
|
|
LOG_INFO( GetLogger(), sLog.c_str())
|
|
return bOk ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeUpdateMachMgr( void)
|
|
{
|
|
IMachMgr* pMachMgr = GetCurrMachMgr() ;
|
|
VERIFY_MACHMGR( pMachMgr, false)
|
|
// aggiornamento gestore lavorazioni
|
|
return pMachMgr->Update() ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeInsertMachMgr( int nInsGrp)
|
|
{
|
|
IMachMgr* pMachMgr = GetCurrMachMgr() ;
|
|
VERIFY_MACHMGR( pMachMgr, false)
|
|
// sposto le macchinate dal gruppo di inserimento alla base macchinate
|
|
return pMachMgr->Insert( nInsGrp) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
int
|
|
ExeGetMachGroupNbr( void)
|
|
{
|
|
IMachMgr* pMachMgr = GetCurrMachMgr() ;
|
|
VERIFY_MACHMGR( pMachMgr, 0)
|
|
// recupero il numero di macchinate
|
|
return pMachMgr->GetMachGroupNbr() ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
int
|
|
ExeGetFirstMachGroup( void)
|
|
{
|
|
IMachMgr* pMachMgr = GetCurrMachMgr() ;
|
|
VERIFY_MACHMGR( pMachMgr, GDB_ID_NULL)
|
|
// recupero la prima macchinata
|
|
return pMachMgr->GetFirstMachGroup() ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
int
|
|
ExeGetNextMachGroup( int nId)
|
|
{
|
|
IMachMgr* pMachMgr = GetCurrMachMgr() ;
|
|
VERIFY_MACHMGR( pMachMgr, GDB_ID_NULL)
|
|
// recupero la successiva macchinata
|
|
return pMachMgr->GetNextMachGroup( nId) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
int
|
|
ExeAddMachGroup( const string& sName, const string& sMachineName)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_MACHMGR( pGseCtx, GDB_ID_NULL)
|
|
// aggiungo la macchinata (gruppo di lavorazione)
|
|
int nId = pGseCtx->m_pMachMgr->AddMachGroup( sName, sMachineName) ;
|
|
pGseCtx->m_bModified = true ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtAddMachGroup('" + sName + "','" +
|
|
sMachineName + "')" +
|
|
" -- Id=" + ToString( nId) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco il risultato
|
|
return nId ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeRemoveMachGroup( int nMGroupId)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_MACHMGR( pGseCtx, false)
|
|
// rimuovo la macchinata (gruppo di lavorazione)
|
|
bool bOk = pGseCtx->m_pMachMgr->RemoveMachGroup( nMGroupId) ;
|
|
pGseCtx->m_bModified = true ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtRemoveMachGroup(" + ToString( nMGroupId) + ")" +
|
|
" -- Ok=" + ToString( bOk) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco il risultato
|
|
return bOk ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeGetMachGroupName( int nId, string& sName)
|
|
{
|
|
IMachMgr* pMachMgr = GetCurrMachMgr() ;
|
|
VERIFY_MACHMGR( pMachMgr, false)
|
|
// recupero il nome della macchinata
|
|
sName = pMachMgr->GetMachGroupName( nId) ;
|
|
return ( ! sName.empty()) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
int
|
|
ExeGetMachGroupId( const string& sName)
|
|
{
|
|
IMachMgr* pMachMgr = GetCurrMachMgr() ;
|
|
VERIFY_MACHMGR( pMachMgr, false)
|
|
// recupero l'indice della macchinata
|
|
return pMachMgr->GetMachGroupId( sName) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeSetCurrMachGroup( int nMGroupId)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_MACHMGR( pGseCtx, false)
|
|
// imposto la macchinata corrente
|
|
bool bOk = pGseCtx->m_pMachMgr->SetCurrMachGroup( nMGroupId) ;
|
|
// non cambia lo stato di modificato del progetto
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtSetCurrMachGroup(" + ToString( nMGroupId) + ")" +
|
|
" -- Ok=" + ToString( bOk) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco il risultato
|
|
return bOk ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeResetCurrMachGroup( void)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_MACHMGR( pGseCtx, false)
|
|
// reset macchinata corrente
|
|
bool bOk = pGseCtx->m_pMachMgr->ResetCurrMachGroup() ;
|
|
// non cambia lo stato di modificato del progetto
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtResetCurrMachGroup()"
|
|
" -- Ok=" + ToString( bOk) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco il risultato
|
|
return bOk ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
int
|
|
ExeGetCurrMachGroup( void)
|
|
{
|
|
IMachMgr* pMachMgr = GetCurrMachMgr() ;
|
|
VERIFY_MACHMGR( pMachMgr, GDB_ID_NULL)
|
|
// restituisco identificativo macchinata corrente
|
|
return pMachMgr->GetCurrMachGroup() ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
int
|
|
ExeGetRawPartNbr( void)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_MACHMGR( pGseCtx, false)
|
|
// recupero il numero di grezzi nella macchinata corrente
|
|
return pGseCtx->m_pMachMgr->GetRawPartNbr() ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
int
|
|
ExeGetFirstRawPart( void)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_MACHMGR( pGseCtx, false)
|
|
// recupero identificativo primo grezzo nella macchinata corrente
|
|
return pGseCtx->m_pMachMgr->GetFirstRawPart() ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
int
|
|
ExeGetNextRawPart( int nRawId)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_MACHMGR( pGseCtx, false)
|
|
// recupero identificativo successivo grezzo nella macchinata corrente
|
|
return pGseCtx->m_pMachMgr->GetNextRawPart( nRawId) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
int
|
|
ExeAddRawPart( Point3d ptOrig, double dWidth, double dLength, double dHeight, Color cCol)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_MACHMGR( pGseCtx, GDB_ID_NULL)
|
|
// inserisco grezzo nella macchinata corrente
|
|
int nId = pGseCtx->m_pMachMgr->AddRawPart( ptOrig, dWidth, dLength, dHeight, cCol) ;
|
|
pGseCtx->m_bModified = true ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtAddRawPart({" + ToString( ptOrig) + "}," +
|
|
ToString( dWidth) + "," +
|
|
ToString( dLength) + "," +
|
|
ToString( dHeight) + ",{" +
|
|
ToString( cCol) + "})" +
|
|
" -- Id=" + ToString( nId) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco il risultato
|
|
return nId ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
int
|
|
ExeAddRawPartWithPart( int nPartId, int nCrvId, double dOverMat, Color cCol)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_MACHMGR( pGseCtx, GDB_ID_NULL)
|
|
// inserisco grezzo con pezzo nella macchinata corrente
|
|
int nId = pGseCtx->m_pMachMgr->AddRawPartWithPart( nPartId, nCrvId, dOverMat, cCol) ;
|
|
pGseCtx->m_bModified = true ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtAddRawPartWithPart(" + ToString( nPartId) + "," +
|
|
ToString( nCrvId) + "," +
|
|
ToString( dOverMat) + ",{" +
|
|
ToString( cCol) + "})" +
|
|
" -- Id=" + ToString( nId) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco il risultato
|
|
return nId ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeModifyRawPartHeight( int nRawId, double dHeight)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_MACHMGR( pGseCtx, false)
|
|
// modifico lo spessore del grezzo
|
|
bool bOk = pGseCtx->m_pMachMgr->ModifyRawPartHeight( nRawId, dHeight) ;
|
|
pGseCtx->m_bModified = true ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtModifyRawPartHeight(" + ToString( nRawId) + "," +
|
|
ToString( dHeight) + ")" +
|
|
" -- Ok=" + ToString( bOk) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco il risultato
|
|
return bOk ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeRemoveRawPart( int nRawId)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_MACHMGR( pGseCtx, false)
|
|
// elimino grezzo dalla macchinata corrente
|
|
bool bOk = pGseCtx->m_pMachMgr->RemoveRawPart( nRawId) ;
|
|
pGseCtx->m_bModified = true ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtRemoveRawPart(" + ToString( nRawId) + ")" +
|
|
" -- Ok=" + ToString( bOk) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco il risultato
|
|
return bOk ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeTranslateRawPart( int nRawId, const Vector3d& vtMove)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_MACHMGR( pGseCtx, false)
|
|
// traslo il grezzo
|
|
bool bOk = pGseCtx->m_pMachMgr->TranslateRawPart( nRawId, vtMove) ;
|
|
pGseCtx->m_bModified = true ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtMoveRawPart(" + ToString( nRawId) + ",{" +
|
|
ToString( vtMove) + "})" +
|
|
" -- Ok=" + ToString( bOk) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco il risultato
|
|
return bOk ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeRotateRawPart( int nRawId, const Vector3d& vtAx, double dAngRotDeg)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_MACHMGR( pGseCtx, false)
|
|
// ruoto il grezzo
|
|
bool bOk = pGseCtx->m_pMachMgr->RotateRawPart( nRawId, vtAx, dAngRotDeg) ;
|
|
pGseCtx->m_bModified = true ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtRotateRawPart(" + ToString( nRawId) + ",{" +
|
|
ToString( vtAx) + "}," +
|
|
ToString( dAngRotDeg) + ")" +
|
|
" -- Ok=" + ToString( bOk) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco il risultato
|
|
return bOk ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeMoveToCornerRawPart( int nRawId, const Point3d& ptCorner, int nFlag)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_MACHMGR( pGseCtx, false)
|
|
// mando il grezzo nel corner
|
|
bool bOk = pGseCtx->m_pMachMgr->MoveToCornerRawPart( nRawId, ptCorner, nFlag) ;
|
|
pGseCtx->m_bModified = true ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtMoveToCornerRawPart(" + ToString( nRawId) + ",{" +
|
|
ToString( ptCorner) + "}," +
|
|
RawPartCornerPosToString( nFlag) + ")" +
|
|
" -- Ok=" + ToString( bOk) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco il risultato
|
|
return bOk ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeMoveToCenterRawPart( int nRawId, const Point3d& ptCenter, int nFlag)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_MACHMGR( pGseCtx, false)
|
|
// mando il grezzo nel corner
|
|
bool bOk = pGseCtx->m_pMachMgr->MoveToCenterRawPart( nRawId, ptCenter, nFlag) ;
|
|
pGseCtx->m_bModified = true ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtMoveToCenterRawPart(" + ToString( nRawId) + ",{" +
|
|
ToString( ptCenter) + "}," +
|
|
RawPartCenterPosToString( nFlag) + ")" +
|
|
" -- Ok=" + ToString( bOk) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco il risultato
|
|
return bOk ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
int
|
|
ExeGetPartInRawPartNbr( int nRawId)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_MACHMGR( pGseCtx, false)
|
|
// recupero il numero di pezzi nel grezzo
|
|
return pGseCtx->m_pMachMgr->GetPartInRawPartNbr( nRawId) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
int
|
|
ExeGetFirstPartInRawPart( int nRawId)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_MACHMGR( pGseCtx, false)
|
|
// recupero identificativo primo pezzo nel grezzo
|
|
return pGseCtx->m_pMachMgr->GetFirstPartInRawPart( nRawId) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
int
|
|
ExeGetNextPartInRawPart( int nPartId)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_MACHMGR( pGseCtx, false)
|
|
// recupero identificativo successivo pezzo nello stesso grezzo
|
|
return pGseCtx->m_pMachMgr->GetNextPartInRawPart( nPartId) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeAddPartToRawPart( int nPartId, const Point3d& ptPos, int nRawId)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_MACHMGR( pGseCtx, false)
|
|
// inserisco pezzo in un grezzo della macchinata corrente
|
|
bool bOk = pGseCtx->m_pMachMgr->AddPartToRawPart( nPartId, ptPos, nRawId) ;
|
|
pGseCtx->m_bModified = true ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtAddPartToRawPart(" + ToString( nPartId) + ",{" +
|
|
ToString( ptPos) + "}," +
|
|
ToString( nRawId) + ")" +
|
|
" -- Ok=" + ToString( bOk) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco il risultato
|
|
return bOk ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeRemovePartFromRawPart( int nPartId)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_MACHMGR( pGseCtx, false)
|
|
// elimino pezzo da grezzo della macchinata corrente
|
|
bool bOk = pGseCtx->m_pMachMgr->RemovePartFromRawPart( nPartId) ;
|
|
pGseCtx->m_bModified = true ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtRemovePartFromRawPart(" + ToString( nPartId) + ")" +
|
|
" -- Ok=" + ToString( bOk) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco il risultato
|
|
return bOk ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeTranslatePartInRawPart( int nPartId, const Vector3d& vtMove)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_MACHMGR( pGseCtx, false)
|
|
// traslo il pezzo nel grezzo
|
|
bool bOk = pGseCtx->m_pMachMgr->TranslatePartInRawPart( nPartId, vtMove) ;
|
|
pGseCtx->m_bModified = true ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtMovePartInRawPart(" + ToString( nPartId) + ",{" +
|
|
ToString( vtMove) + "})" +
|
|
" -- Ok=" + ToString( bOk) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco il risultato
|
|
return bOk ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeRotatePartInRawPart( int nPartId, const Vector3d& vtAx, double dAngRotDeg)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_MACHMGR( pGseCtx, false)
|
|
// ruoto il pezzo nel grezzo
|
|
bool bOk = pGseCtx->m_pMachMgr->RotatePartInRawPart( nPartId, vtAx, dAngRotDeg) ;
|
|
pGseCtx->m_bModified = true ;
|
|
// se richiesto, salvo il comando Lua equivalente
|
|
if ( IsCmdLog()) {
|
|
string sLua = "EgtRotatePartInRawPart(" + ToString( nPartId) + ",{" +
|
|
ToString( vtAx) + "}," +
|
|
ToString( dAngRotDeg) + ")" +
|
|
" -- Ok=" + ToString( bOk) ;
|
|
LOG_INFO( GetCmdLogger(), sLua.c_str()) ;
|
|
}
|
|
// restituisco il risultato
|
|
return bOk ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
int
|
|
ExeAddSubPiece( const string& sName, const Point3d& ptPos)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_MACHMGR( pGseCtx, false)
|
|
// inserisco il sottopezzo nella posizione indicata
|
|
return pGseCtx->m_pMachMgr->AddSubPiece( sName, ptPos) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeSetAxisPos( const string& sAxis, double dVal)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_MACHMGR( pGseCtx, false)
|
|
// metto l'asse nella nuova posizione
|
|
return pGseCtx->m_pMachMgr->SetAxisPos( sAxis, dVal) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeGetAxisPos( const string& sAxis, double* pdVal)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_MACHMGR( pGseCtx, false)
|
|
// verifico il parametro di ritorno
|
|
if ( pdVal == nullptr)
|
|
return false ;
|
|
// metto l'asse nella nuova posizione
|
|
return pGseCtx->m_pMachMgr->GetAxisPos( sAxis, *pdVal) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeGetAxisHomePos( const string& sAxis, double* pdHomeVal)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_MACHMGR( pGseCtx, false)
|
|
// verifico il parametro di ritorno
|
|
if ( pdHomeVal == nullptr)
|
|
return false ;
|
|
// metto l'asse nella nuova posizione
|
|
return pGseCtx->m_pMachMgr->GetAxisHomePos( sAxis, *pdHomeVal) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeResetAxisPos( const string& sAxis)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_MACHMGR( pGseCtx, false)
|
|
// metto l'asse nella posizione home
|
|
return pGseCtx->m_pMachMgr->ResetAxisPos( sAxis) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeLoadTool( const string& sHead, int nExit, const string& sTool)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_MACHMGR( pGseCtx, false)
|
|
// carico l'utensile sulla macchina della macchinata corrente in posizione indicata
|
|
return pGseCtx->m_pMachMgr->LoadTool( sHead, nExit, sTool) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeResetHeadSet( const string& sHead)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_MACHMGR( pGseCtx, false)
|
|
// carico l'utensile sulla macchina della macchinata corrente in posizione indicata
|
|
return pGseCtx->m_pMachMgr->ResetHeadSet( sHead) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeSetCalcTable( const std::string& sTable)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_MACHMGR( pGseCtx, false)
|
|
// imposto la tavola corrente per il calcolo sulla macchina della macchinata corrente
|
|
return pGseCtx->m_pMachMgr->SetCalcTable( sTable) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeSetCalcTool( const std::string& sTool, const std::string& sHead, int nExit)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_MACHMGR( pGseCtx, false)
|
|
// imposto l'utensile corrente per il calcolo sulla macchina della macchinata corrente
|
|
return pGseCtx->m_pMachMgr->SetCalcTool( sTool, sHead, nExit) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeGetCalcAngles( const Vector3d& vtDirT, const Vector3d& vtDirA,
|
|
int& nStat, double& dAngA1, double& dAngB1, double& dAngA2, double& dAngB2)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_MACHMGR( pGseCtx, false)
|
|
// calcolo gli angoli macchina dalle direzioni fresa e ausiliaria passate
|
|
return pGseCtx->m_pMachMgr->GetCalcAngles( vtDirT, vtDirA, nStat, dAngA1, dAngB1, dAngA2, dAngB2) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeGetCalcPositions( const Point3d& ptP, double dAngA, double dAngB,
|
|
int& nStat, double& dX, double& dY, double& dZ)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_MACHMGR( pGseCtx, false)
|
|
// calcolo gli angoli macchina dalla direzione fresa passata
|
|
return pGseCtx->m_pMachMgr->GetCalcPositions( ptP, dAngA, dAngB, nStat, dX, dY, dZ) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
bool
|
|
ExeVerifyOutOfStroke( double dX, double dY, double dZ, double dAngA, double dAngB, int& nStat)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_MACHMGR( pGseCtx, false)
|
|
// verifica l'extracorsa degli assi
|
|
return pGseCtx->m_pMachMgr->VerifyOutOfStroke( dX, dY, dZ, dAngA, dAngB, nStat) ;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
int
|
|
ExeAddDrilling( const string& sName)
|
|
{
|
|
GseContext* pGseCtx = GetCurrGseContext() ;
|
|
VERIFY_CTX_MACHMGR( pGseCtx, false)
|
|
// verifica l'extracorsa degli assi
|
|
return pGseCtx->m_pMachMgr->AddDrilling( sName) ;
|
|
}
|