EgtMachKernel 1.6x5 :

- ora OnSpecialApplyDisposition gestisce anche TcPos
- aggiunta possibilità di richiamo OnPostApplyMachining al termine ricalcolo lavorazione
- aggiunta funzione Lua EmtGetAxesPos
- piccole migliorie a simulazione.
This commit is contained in:
Dario Sassi
2017-01-03 09:18:22 +00:00
parent 3587b88a61
commit d9c080c6d6
14 changed files with 142 additions and 21 deletions
+23 -11
View File
@@ -44,6 +44,7 @@ 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" ;
static std::string DIS_TCPOS = "TcPos" ;
static std::string DIS_SOMEBYHAND = "Sbh" ;
//----------------------------------------------------------------------------
static double DISP_BOX_TOL = - 0.5 ;
@@ -74,6 +75,7 @@ Disposition::Clone( void) const
pDisp->m_vMvrData = m_vMvrData ;
pDisp->m_sHead = m_sHead ;
pDisp->m_nExit = m_nExit ;
pDisp->m_sTcPos = m_sTcPos ;
pDisp->m_nShifts = m_nShifts ;
pDisp->m_bSomeByHand = m_bSomeByHand ;
}
@@ -122,6 +124,7 @@ Disposition::Dump( string& sOut, bool bMM, const char* szNewLine) const
sOut += "Num=" + ToString( m_nShifts) + szNewLine ;
sOut += "Head=" + m_sHead + szNewLine ;
sOut += "Exit=" + ToString( m_nExit) + szNewLine ;
sOut += "TcPos=" + m_sTcPos + szNewLine ;
sOut += "ByHand=" + ToString( m_bSomeByHand) + szNewLine ;
return true ;
}
@@ -136,7 +139,7 @@ Disposition::Save( STRVECTOR& vString) const
int nFxdLines = 1 + 4 * nFxdTot ;
int nMvdTot = int( m_vMvrData.size()) ;
int nMvdLines = 1 + 4 * nMvdTot ;
int nOther = 4 ;
int nOther = 5 ;
vString.insert( vString.begin(), 4 + nFxdLines + nMvdLines + nOther, "") ;
// Nome
if ( ! SetVal( DIS_TABLE, m_sTabName, vString[++k]))
@@ -179,6 +182,8 @@ Disposition::Save( STRVECTOR& vString) const
return false ;
if ( ! SetVal( DIS_SOMEBYHAND, m_bSomeByHand, vString[++k]))
return false ;
if ( ! SetVal( DIS_TCPOS, m_sTcPos, vString[++k]))
return false ;
}
catch( ...) { return false ; }
return true ;
@@ -257,6 +262,10 @@ Disposition::Load( const STRVECTOR& vString, int nBaseGdbId)
if ( ! GetVal( vString[++k], DIS_SOMEBYHAND, m_bSomeByHand))
return false ;
}
if ( k + 1 < int( vString.size())) {
if ( ! GetVal( vString[++k], DIS_TCPOS, m_sTcPos))
return false ;
}
return true ;
}
@@ -1005,16 +1014,12 @@ bool
Disposition::SpecialApply( bool bRecalc)
{
// reset
m_sHead.empty() ;
m_sHead.clear() ;
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 ;
m_bSomeByHand = false ;
m_sTcPos.clear() ;
// costanti
static const string EMC_VAR = "EMC" ; // tabella variabili locali per calcolo
static const string EVAR_TABNAME = ".TABNAME" ; // IN (string) nome della tavola macchina
@@ -1027,10 +1032,17 @@ Disposition::SpecialApply( bool bRecalc)
static const string EVAR_SBH = ".SBH" ; // OUT (bool) flag presenza operazioni manuali
static const string ON_SPECIAL_APPLY = "OnSpecialApplyDisposition" ;
// recupero la macchina corrente
Machine* pMch = m_pMchMgr->GetCurrMachine() ;
if ( pMch == nullptr)
return false ;
// eseguo l'azione
if ( pMch->LuaExistsFunction( ON_SPECIAL_APPLY)) {
bool bOk = true ;
int nErr = 99 ;
// verifico tavola
bOk = ( m_bTabOk || SetTable( m_sTabName)) ;
// imposto valori parametri
bOk = bOk && pMch->LuaCreateGlobTable( EMC_VAR) ;
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_TABNAME, m_sTabName) ;
@@ -1044,8 +1056,8 @@ Disposition::SpecialApply( bool bRecalc)
bOk = bOk && pMch->LuaGetGlobVar( EMC_VAR + EVAR_SHIFTS, m_nShifts) ;
bOk = bOk && pMch->LuaGetGlobVar( EMC_VAR + EVAR_SBH, m_bSomeByHand) ;
// recupero valori parametri opzionali
if ( ! pMch->LuaGetGlobVar( EMC_VAR + EVAR_TCPOS, m_sTcPos))
m_sTcPos.clear() ;
if ( bOk)
pMch->LuaGetGlobVar( EMC_VAR + EVAR_TCPOS, m_sTcPos) ;
// reset
bOk = bOk && pMch->LuaResetGlobVar( EMC_VAR) ;
// segnalo errori
+4
View File
@@ -475,6 +475,10 @@ Drilling::Apply( bool bRecalc)
if ( ! AdjustStartEndMovements())
return false ;
// esecuzione eventuale personalizzazioni
if ( ! PostApply())
return false ;
return true ;
}
BIN
View File
Binary file not shown.
+1
View File
@@ -247,6 +247,7 @@ class Machine
static int LuaEmtAddRapidStart( lua_State* L) ;
static int LuaEmtAddRapidMove( lua_State* L) ;
static int LuaEmtAddLinearMove( lua_State* L) ;
static int LuaEmtGetAxesPos( lua_State* L) ;
static int LuaEmtLinkRawPartToGroup( lua_State* L) ;
static int LuaEmtUnlinkRawPartFromGroup( lua_State* L) ;
static int LuaEmtUnlinkAllRawPartsFromGroups( lua_State* L) ;
+2
View File
@@ -95,6 +95,8 @@ Machine::LuaInit( const string& sMachineName)
m_LuaMgr.RegisterFunction( "EmtAddRapidStart", Machine::LuaEmtAddRapidStart) ;
m_LuaMgr.RegisterFunction( "EmtAddRapidMove", Machine::LuaEmtAddRapidMove) ;
m_LuaMgr.RegisterFunction( "EmtAddLinearMove", Machine::LuaEmtAddLinearMove) ;
// registro le funzioni di lettura entità CL per lua
m_LuaMgr.RegisterFunction( "EmtGetAxesPos", Machine::LuaEmtGetAxesPos) ;
// registro le funzioni di scrittura part program per lua
m_LuaMgr.RegisterFunction( "EmtWrite", Machine::LuaEmtWrite) ;
+26
View File
@@ -190,3 +190,29 @@ Machine::LuaEmtAddLinearMove( lua_State* L)
LuaSetParam( L) ;
return 1 ;
}
//----------------------------------------------------------------------------
int
Machine::LuaEmtGetAxesPos( lua_State* L)
{
// 1 parametri : nClEntId
int nClEntId ;
LuaCheckParam( L, 1, nClEntId)
LuaClearStack( L) ;
// verifico ci sia una macchina attiva valida
if ( m_pMchLua == nullptr ||
m_pMchLua->m_pMchMgr == nullptr || m_pMchLua->m_pGeomDB == nullptr)
return luaL_error( L, " Unknown Machine") ;
// recupero l'oggetto CamData
const CamData* pCamData = GetCamData( m_pMchLua->m_pGeomDB->GetUserObj( nClEntId)) ;
bool bOk = ( pCamData != nullptr) ;
bOk = bOk && pCamData->GetAxesStatus() == CamData::AS_OK ;
if ( bOk) {
DBLVECTOR AxesVal = pCamData->GetAxesVal() ;
LuaSetParam( L, AxesVal) ;
}
else
LuaSetParam( L) ;
return 1 ;
}
+43
View File
@@ -70,3 +70,46 @@ Machining:: NeedPrevHome( void) const
{
return false ;
}
//----------------------------------------------------------------------------
bool
Machining::PostApply( void)
{
// 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_PHASE = ".PHASE" ; // IN (int) indice fase
static const string EVAR_MCHID = ".MCHID" ; // IN (int) identificativo della lavorazione
static const string EVAR_ERROR = ".ERR" ; // OUT (int) codice di errore ( 0 = ok)
static const string ON_POST_APPLY = "OnPostApplyMachining" ;
// eseguo l'azione
if ( pMch->LuaExistsFunction( ON_POST_APPLY)) {
bool bOk = true ;
int nErr = 99 ;
// imposto valori parametri
bOk = bOk && pMch->LuaCreateGlobTable( EMC_VAR) ;
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_PHASE, m_nPhase) ;
bOk = bOk && pMch->LuaSetGlobVar( EMC_VAR + EVAR_MCHID, m_nOwnerId) ;
// eseguo
bOk = bOk && pMch->LuaCallFunction( ON_POST_APPLY) ;
// recupero valori parametri obbligatori
bOk = bOk && pMch->LuaGetGlobVar( EMC_VAR + EVAR_ERROR, nErr) ;
// recupero valori parametri opzionali
// ...
// reset
bOk = bOk && pMch->LuaResetGlobVar( EMC_VAR) ;
// segnalo errori
if ( nErr != 0) {
bOk = false ;
string sOut = " Error in " + ON_POST_APPLY + " (" + ToString( nErr) + ")" ;
LOG_INFO( GetEMkLogger(), sOut.c_str())
}
return bOk ;
}
else
return true ;
}
+3
View File
@@ -42,6 +42,9 @@ class Machining : public Operation
virtual const ToolData& GetToolData( void) const = 0 ;
virtual bool GetGeometry( SELVECTOR& vIds) const = 0 ;
public :
bool PostApply( void) ;
protected :
Machining( void) ;
} ;
+4
View File
@@ -520,6 +520,10 @@ Milling::Apply( bool bRecalc)
if ( ! AdjustStartEndMovements())
return false ;
// esecuzione eventuale personalizzazioni
if ( ! PostApply())
return false ;
return true ;
}
+4
View File
@@ -451,6 +451,10 @@ SawFinishing::Apply( bool bRecalc)
if ( ! AdjustStartEndMovements())
return false ;
// esecuzione eventuale personalizzazioni
if ( ! PostApply())
return false ;
return true ;
}
+4
View File
@@ -430,6 +430,10 @@ SawRoughing::Apply( bool bRecalc)
if ( ! AdjustStartEndMovements())
return false ;
// esecuzione eventuale personalizzazioni
if ( ! PostApply())
return false ;
return true ;
}
+4
View File
@@ -537,6 +537,10 @@ Sawing::Apply( bool bRecalc)
if ( ! AdjustStartEndMovements())
return false ;
// esecuzione eventuale personalizzazioni
if ( ! PostApply())
return false ;
return true ;
}
+23 -10
View File
@@ -657,6 +657,20 @@ Simulator::UpdateAxesPos( void)
return true ;
}
//----------------------------------------------------------------------------
bool
Simulator::ResetAuxAxes( void)
{
// pulisco dati assi ausiliari
m_AuxAxesName.clear() ;
m_AuxAxesToken.clear() ;
m_AuxAxesInvert.clear() ;
m_AuxAxesLinear.clear() ;
m_AuxAxesVal.clear() ;
m_AuxAxesEnd.clear() ;
return true ;
}
//----------------------------------------------------------------------------
bool
Simulator::OnOperationEnd( void)
@@ -868,14 +882,6 @@ Simulator::OnPathEnd( void)
bool
Simulator::OnMoveStart( const CamData* pCamData)
{
// pulisco dati assi ausiliari
m_AuxAxesName.clear() ;
m_AuxAxesToken.clear() ;
m_AuxAxesInvert.clear() ;
m_AuxAxesLinear.clear() ;
m_AuxAxesVal.clear() ;
m_AuxAxesEnd.clear() ;
// recupero e assegno i dati
// dati generali
bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_MOVEID, m_nEntId) ;
@@ -899,16 +905,23 @@ Simulator::OnMoveStart( const CamData* pCamData)
bOk = bOk && m_pMachine->LuaResetGlobVar( GLOB_VAR + GVAR_AUXAXES) ;
// verifico esistenza funzione
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_MOVE_START))
if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_MOVE_START)) {
ResetAuxAxes() ;
return bOk ;
}
// chiamo la funzione
bOk = bOk && m_pMachine->LuaCallFunction( ON_SIMUL_MOVE_START) ;
if ( ! bOk)
if ( ! bOk) {
ResetAuxAxes() ;
return false ;
}
// forzo aggiornamento posizione assi (possono essere stati mossi nello script)
UpdateAxesPos() ;
// reset assi ausiliari
ResetAuxAxes() ;
// recupero i dati di ritorno
int nNumAuxAxes = 0 ;
if ( ! m_pMachine->LuaGetGlobVar( GLOB_VAR + GVAR_AUXAXES, nNumAuxAxes) || nNumAuxAxes == 0)
+1
View File
@@ -40,6 +40,7 @@ class Simulator
bool UpdateTool( bool bForced = false) ;
bool UpdateAxes( void) ;
bool UpdateAxesPos( void) ;
bool ResetAuxAxes( void) ;
private :
bool OnOperationEnd( void) ;