EgtMachKernel :

- aggiunta gestione prima disposizione in lista operazioni
- migliorato controllo dati macchina al caricamento
- ora macchina deve essere disegnata e definita cinematicamente con tutti gli assi a 0,
  si definisce la posizione home e dopo il carico viene posta in questa posizione.
This commit is contained in:
Dario Sassi
2015-05-31 14:10:00 +00:00
parent 4f150f773c
commit b373807375
27 changed files with 1306 additions and 327 deletions
+40 -17
View File
@@ -45,9 +45,9 @@ Machine::LuaInit( const string& sMachineName)
sLua += " (" + sMachineName + ")" ;
LOG_INFO( GetEMkLogger(), sLua.c_str())
// imposto il direttorio delle librerie
m_LuaMgr.SetLuaLibsDir( m_pMchMgr->m_sLuaLibsDir) ;
m_LuaMgr.SetLuaLibsDir( m_pMchMgr->GetLuaLibsDir()) ;
// carico la libreria standard
m_LuaMgr.Require( m_pMchMgr->m_sLuaLastRequire) ;
m_LuaMgr.Require( m_pMchMgr->GetLuaLastRequire()) ;
// registro le funzioni per lua
m_LuaMgr.RegisterFunction( "EmtGeneral", Machine::LuaEmtGeneral) ;
m_LuaMgr.RegisterFunction( "EmtBase", Machine::LuaEmtBase) ;
@@ -74,16 +74,19 @@ Machine::LuaExit( void)
bool
Machine::LuaExecFile( const string& sFile)
{
// info
string sOut = "LuaExecFile : " + sFile ;
ExeOutLog( sOut) ;
// imposto contesto corretto
int nOldCtx = ExeGetCurrentContext() ;
if ( nOldCtx != m_pMchMgr->m_nContextId)
ExeSetCurrentContext( m_pMchMgr->m_nContextId) ;
if ( nOldCtx != m_pMchMgr->GetContextId())
ExeSetCurrentContext( m_pMchMgr->GetContextId()) ;
// imposto l'oggetto corrente per Lua
m_pMchLua = this ;
// carico la macchina
bool bOk = m_LuaMgr.ExecFile( sFile) ;
// ripristino contesto originale
if ( nOldCtx != m_pMchMgr->m_nContextId)
if ( nOldCtx != m_pMchMgr->GetContextId())
ExeSetCurrentContext( nOldCtx) ;
return bOk ;
}
@@ -92,7 +95,6 @@ Machine::LuaExecFile( const string& sFile)
int
Machine::LuaEmtGeneral( lua_State* L)
{
ExeOutLog( "LuaEmtGeneral") ;
// Il parametro 1 deve essere una tabella
if ( ! lua_istable( L, 1))
return luaL_error( L, " Invalid Parameter, required a table") ;
@@ -104,6 +106,10 @@ Machine::LuaEmtGeneral( lua_State* L)
LuaGetTabFieldParam( L, 1, "Offset", vtOffset) ;
LuaClearStack( L) ;
// info
string sOut = "LuaEmtGeneral : " + sFile ;
ExeOutLog( sOut) ;
// verifico ci sia una macchina attiva
if ( m_pMchLua == nullptr)
return luaL_error( L, " Unknown Machine") ;
@@ -119,7 +125,6 @@ Machine::LuaEmtGeneral( lua_State* L)
int
Machine::LuaEmtBase( lua_State* L)
{
ExeOutLog( "LuaEmtBase") ;
// Il parametro 1 deve essere una tabella
if ( ! lua_istable( L, 1))
return luaL_error( L, " Invalid Parameter, required a table") ;
@@ -131,6 +136,10 @@ Machine::LuaEmtBase( lua_State* L)
LuaCheckTabFieldParam( L, 1, "Geo", sGeo)
LuaClearStack( L) ;
// info
string sOut = "LuaEmtBase : " + sName ;
ExeOutLog( sOut) ;
// verifico ci sia una macchina attiva
if ( m_pMchLua == nullptr)
return luaL_error( L, " Unknown Machine") ;
@@ -146,7 +155,6 @@ Machine::LuaEmtBase( lua_State* L)
int
Machine::LuaEmtTable( lua_State* L)
{
ExeOutLog( "LuaEmtTable") ;
// Il parametro 1 deve essere una tabella
if ( ! lua_istable( L, 1))
return luaL_error( L, " Invalid Parameter, required a table") ;
@@ -159,17 +167,24 @@ Machine::LuaEmtTable( lua_State* L)
// lettura campo 'Type' dalla tabella
int nType ;
LuaCheckTabFieldParam( L, 1, "Type", nType)
// lettura campo 'Ref1' dalla tabella
Point3d Ref1 ;
LuaCheckTabFieldParam( L, 1, "Ref1", Ref1)
// lettura campo 'Geo' dalla tabella
string sGeo ;
LuaCheckTabFieldParam( L, 1, "Geo", sGeo)
LuaClearStack( L) ;
// info
string sOut = "LuaEmtTable : " + sName ;
ExeOutLog( sOut) ;
// verifico ci sia una macchina attiva
if ( m_pMchLua == nullptr)
return luaL_error( L, " Unknown Machine") ;
// carico i dati della tavola
if ( ! m_pMchLua->LoadMachineTable( sName, sParent, nType, sGeo))
if ( ! m_pMchLua->LoadMachineTable( sName, sParent, nType, Ref1, sGeo))
return luaL_error( L, " Load Machine Table failed") ;
return 0 ;
@@ -179,7 +194,6 @@ Machine::LuaEmtTable( lua_State* L)
int
Machine::LuaEmtAxis( lua_State* L)
{
ExeOutLog( "LuaEmtAxis") ;
// Il parametro 1 deve essere una tabella
if ( ! lua_istable( L, 1))
return luaL_error( L, " Invalid Parameter, required a table") ;
@@ -204,17 +218,21 @@ Machine::LuaEmtAxis( lua_State* L)
// lettura campo 'Geo' dalla tabella
string sGeo ;
LuaCheckTabFieldParam( L, 1, "Geo", sGeo)
// lettura eventuale campo 'Val' dalla tabella (default 0)
double dVal = 0 ;
LuaGetTabFieldParam( L, 1, "Val", dVal) ;
// lettura eventuale campo 'Home' dalla tabella (default 0)
double dHome = 0 ;
LuaGetTabFieldParam( L, 1, "Home", dHome) ;
LuaClearStack( L) ;
// info
string sOut = "LuaEmtAxis : " + sName ;
ExeOutLog( sOut) ;
// verifico ci sia una macchina attiva
if ( m_pMchLua == nullptr)
return luaL_error( L, " Unknown Machine") ;
// carico i dati dell'asse
if ( ! m_pMchLua->LoadMachineAxis( sName, sParent, nType, ptPos, vtDir, Stroke, sGeo, dVal))
if ( ! m_pMchLua->LoadMachineAxis( sName, sParent, nType, ptPos, vtDir, Stroke, sGeo, dHome))
return luaL_error( L, " Load Machine Axis failed") ;
return 0 ;
@@ -224,7 +242,6 @@ Machine::LuaEmtAxis( lua_State* L)
int
Machine::LuaEmtHead( lua_State* L)
{
ExeOutLog( "LuaEmtHead") ;
// Il parametro 1 deve essere una tabella
if ( ! lua_istable( L, 1))
return luaL_error( L, " Invalid Parameter, required a table") ;
@@ -245,7 +262,6 @@ Machine::LuaEmtHead( lua_State* L)
int
Machine::LuaEmtStdHead( lua_State* L)
{
ExeOutLog( " Standard Head") ;
// Il parametro 1 deve essere una tabella
if ( ! lua_istable( L, 1))
return luaL_error( L, " Invalid Parameter, required a table") ;
@@ -272,6 +288,10 @@ Machine::LuaEmtStdHead( lua_State* L)
LuaCheckTabFieldParam( L, 1, "Geo", sGeo)
LuaClearStack( L) ;
// info
string sOut = "LuaEmtStdHead : " + sName ;
ExeOutLog( sOut) ;
// verifico ci sia una macchina attiva
if ( m_pMchLua == nullptr)
return luaL_error( L, " Unknown Machine") ;
@@ -287,7 +307,6 @@ Machine::LuaEmtStdHead( lua_State* L)
int
Machine::LuaEmtMultiHead( lua_State* L)
{
ExeOutLog( " Multiple Head") ;
// Il parametro 1 deve essere una tabella
if ( ! lua_istable( L, 1))
return luaL_error( L, " Invalid Parameter, required a table") ;
@@ -325,6 +344,10 @@ Machine::LuaEmtMultiHead( lua_State* L)
LuaCheckTabFieldParam( L, 1, "Geo", sGeo)
LuaClearStack( L) ;
// info
string sOut = "LuaEmtMultiHead : " + sName ;
ExeOutLog( sOut) ;
// verifico ci sia una macchina attiva
if ( m_pMchLua == nullptr)
return luaL_error( L, " Unknown Machine") ;