EgtMachKernel 1.6p4 :

- ampliata Disposizione con gestione movimenti di pezzi con la testa tramite SpecialApply (che richiama script)
- modifiche a Simulatore per gestire queste disposizioni e aggiunti richiami script su diversi eventi
- modifiche a Generatore per gestire queste disposizioni
- varie altre modifiche e migliorie.
This commit is contained in:
Dario Sassi
2016-05-05 07:31:35 +00:00
parent 06a8b15d99
commit b8965da858
37 changed files with 3234 additions and 1898 deletions
+139 -50
View File
@@ -1,8 +1,8 @@
//----------------------------------------------------------------------------
// EgalTech 2015-2015
// EgalTech 2015-2016
//----------------------------------------------------------------------------
// File : Drilling.cpp Data : 21.05.15 Versione : 1.6e7
// Contenuto : Implementazione gestione forature.
// File : Drilling.cpp Data : 29.04.16 Versione : 1.6p4
// Contenuto : Implementazione gestione disposizione.
//
//
//
@@ -16,8 +16,8 @@
#include "MachMgr.h"
#include "DllMain.h"
#include "Disposition.h"
#include "Table.h"
#include "/EgtDev/Include/EMkDispositionConst.h"
#include "/EgtDev/Include/EGkAngle.h"
#include "/EgtDev/Include/EGkStringUtils3d.h"
#include "/EgtDev/Include/EGkUserObjFactory.h"
#include "/EgtDev/Include/EGnStringKeyVal.h"
@@ -40,6 +40,9 @@ static std::string DIS_MVD_TYPE = "MvT" ;
static std::string DIS_MVD_PNT = "MvP" ;
static std::string DIS_MVD_ANG = "MvA" ;
static std::string DIS_MVD_FLAG = "MvF" ;
static std::string DIS_NUM = "NUM" ;
static std::string DIS_HEAD = "Head" ;
static std::string DIS_EXIT = "Exit" ;
//----------------------------------------------------------------------------
USEROBJ_REGISTER( "EMkDisposition", Disposition) ;
@@ -65,6 +68,9 @@ Disposition::Clone( void) const
pDisp->m_bTabOk = m_bTabOk ;
pDisp->m_vFixData = m_vFixData ;
pDisp->m_vMvrData = m_vMvrData ;
pDisp->m_sHead = m_sHead ;
pDisp->m_nExit = m_nExit ;
pDisp->m_nShifts = m_nShifts ;
}
catch( ...) {
delete pDisp ;
@@ -107,6 +113,9 @@ Disposition::Dump( string& sOut, bool bMM, const char* szNewLine) const
break ;
}
}
sOut += "Num=" + ToString( m_nShifts) + szNewLine ;
sOut += "Head=" + m_sHead + szNewLine ;
sOut += "Exit=" + ToString( m_nExit) + szNewLine ;
return true ;
}
@@ -120,7 +129,8 @@ Disposition::Save( STRVECTOR& vString) const
int nFxdLines = 1 + 3 * nFxdTot ;
int nMvdTot = int( m_vMvrData.size()) ;
int nMvdLines = 1 + 4 * nMvdTot ;
vString.insert( vString.begin(), 4 + nFxdLines + nMvdLines, "") ;
int nOther = 3 ;
vString.insert( vString.begin(), 4 + nFxdLines + nMvdLines + nOther, "") ;
// Nome
if ( ! SetVal( DIS_TABLE, m_sTabName, vString[++k]))
return false ;
@@ -152,6 +162,13 @@ Disposition::Save( STRVECTOR& vString) const
! SetVal( DIS_MVD_FLAG, MvrData.nFlag, vString[++k]))
return false ;
}
// altri dati
if ( ! SetVal( DIS_NUM, m_nShifts, vString[++k]))
return false ;
if ( ! SetVal( DIS_HEAD, m_sHead, vString[++k]))
return false ;
if ( ! SetVal( DIS_EXIT, m_nExit, vString[++k]))
return false ;
}
catch( ...) { return false ; }
return true ;
@@ -206,53 +223,27 @@ Disposition::Load( const STRVECTOR& vString)
! GetVal( vString[++k], DIS_MVD_FLAG, MvrData.nFlag))
return false ;
}
// altri dati aggiuntivi
if ( k + 1 < int( vString.size())) {
if ( ! GetVal( vString[++k], DIS_NUM, m_nShifts))
return false ;
}
if ( k + 1 < int( vString.size())) {
if ( ! GetVal( vString[++k], DIS_HEAD, m_sHead))
return false ;
}
if ( k + 1 < int( vString.size())) {
if ( ! GetVal( vString[++k], DIS_EXIT, m_nExit))
return false ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
Disposition::SetOwner( int nId, IGeomDB* pGDB)
{
m_nOwnerId = nId ;
m_pGeomDB = pGDB ;
return ( m_nOwnerId != GDB_ID_NULL && m_pGeomDB != nullptr) ;
}
//----------------------------------------------------------------------------
int
Disposition::GetOwner( void) const
{
return m_nOwnerId ;
}
//----------------------------------------------------------------------------
IGeomDB*
Disposition::GetGeomDB( void) const
{
return m_pGeomDB ;
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
Disposition::Disposition( void)
: m_bTabOk( false), m_nExit( 0), m_nShifts( 0)
{
m_nOwnerId = GDB_ID_NULL ;
m_pGeomDB = nullptr ;
m_pMchMgr = nullptr ;
m_bTabOk = false ;
m_nPhase = 1 ;
}
//----------------------------------------------------------------------------
bool
Disposition::Init( MachMgr* pMchMgr)
{
m_pMchMgr = pMchMgr ;
if ( m_pMchMgr == nullptr)
return false ;
if ( m_pMchMgr->GetGeomDB() != m_pGeomDB)
return false ;
return true ;
}
//----------------------------------------------------------------------------
@@ -272,12 +263,10 @@ Disposition::SetTable( const string& sTable)
if ( ! pMch->SetCurrTable( sTable))
return false ;
// recupero il primo riferimento e l'area utile della tavola
Table* pTab = pMch->GetTable( sTable) ;
if ( pTab == nullptr)
return false ;
Point3d ptPrevRef1 = m_ptRef1 ;
m_ptRef1 = pTab->GetRef1() ;
m_b3Area1 = pTab->GetArea1() ;
if ( ! pMch->GetCurrTableRef1( m_ptRef1) ||
! pMch->GetCurrTableArea1( m_b3Area1))
return false ;
if ( ! m_sTabName.empty() && EqualNoCase( m_sTabName, sTable) &&
! AreSamePointApprox( ptPrevRef1, m_ptRef1)) {
string sOut = "Table Ref1 changed : (" + ToString( ptPrevRef1) + ") -> (" + ToString( m_ptRef1) +")" ;
@@ -771,3 +760,103 @@ Disposition::GetMoveRawData( int nInd, int& nRawId, int& nType, Point3d& ptPos,
nFlag = m_vMvrData[nInd].nFlag ;
return true ;
}
//----------------------------------------------------------------------------
bool
Disposition::SpecialApply( bool bRecalc)
{
// reset
m_sHead.empty() ;
m_nExit = 0 ;
m_nShifts = 0 ;
// verifico tavola
if ( ! m_bTabOk && ! SetTable( m_sTabName))
return false ;
// recupero la macchina corrente
Machine* pMch = m_pMchMgr->GetCurrMachine() ;
if ( pMch == nullptr)
return false ;
// costanti
static const string EMC_VAR = "EMC" ; // tabella variabili locali per calcolo
static const string EVAR_TABNAME = ".TABNAME" ; // IN (string) nome della tavola macchina
static const string EVAR_DISPID = ".DISPID" ; // IN (int) identificativo della disposizione
static const string EVAR_ERROR = ".ERR" ; // OUT (int) codice di errore ( 0 = ok)
static const string EVAR_HEAD = ".HEAD" ; // OUT (string) nome della testa
static const string EVAR_EXIT = ".EXIT" ; // OUT (int) indice dell'uscita
static const string EVAR_SHIFTS = ".SHIFTS" ; // OUT (int) numero di movimenti eseguiti
static const string ON_SPECIAL_APPLY = "OnSpecialApplyDisposition" ;
// eseguo l'azione
if ( pMch->LuaExistsFunction( ON_SPECIAL_APPLY)) {
bool bOk = true ;
int nErr = 99 ;
// imposto valori parametri
bOk = bOk && pMch->LuaCreateGlobTable( EMC_VAR) ;
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_TABNAME, m_sTabName) ;
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_DISPID, m_nOwnerId) ;
// eseguo
bOk = bOk && pMch->LuaCallFunction( ON_SPECIAL_APPLY) ;
// recupero valori parametri
bOk = bOk && pMch->LuaGetGlobVar( EMC_VAR + EVAR_ERROR, nErr) ;
bOk = bOk && pMch->LuaGetGlobVar( EMC_VAR + EVAR_HEAD, m_sHead) ;
bOk = bOk && pMch->LuaGetGlobVar( EMC_VAR + EVAR_EXIT, m_nExit) ;
bOk = bOk && pMch->LuaGetGlobVar( EMC_VAR + EVAR_SHIFTS, m_nShifts) ;
bOk = bOk && pMch->LuaResetGlobVar( EMC_VAR) ;
// segnalo errori
if ( nErr != 0) {
bOk = false ;
string sOut = " Error in " + ON_SPECIAL_APPLY + " (" + ToString( nErr) + ")" ;
LOG_INFO( GetEMkLogger(), sOut.c_str())
}
// se disposizione vuota, esco
if ( m_nShifts == 0)
return bOk ;
// calcolo assi macchina
bOk = bOk && CalculateAxesValues() ;
// gestione movimenti all'inizio di ogni singolo percorso di lavorazione e alla fine di tutti
bOk = bOk && AdjustStartEndMovements() ;
return bOk ;
}
else
return true ;
}
//----------------------------------------------------------------------------
bool
Disposition::GetToolData( string& sName, string& sHead, int& nExit) const
{
sName = "" ;
sHead = m_sHead ;
nExit = m_nExit ;
return true ;
}
//----------------------------------------------------------------------------
const string&
Disposition::GetToolName( void) const
{
static string sDummy = "" ;
return sDummy ;
}
//----------------------------------------------------------------------------
const string&
Disposition::GetHeadName( void) const
{
return m_sHead ;
}
//----------------------------------------------------------------------------
int
Disposition::GetExitNbr( void) const
{
return m_nExit ;
}
//----------------------------------------------------------------------------
const string&
Disposition::GetToolTcPos( void) const
{
static string sDummy = "" ;
return sDummy ;
}