EgtExecutor 2.1g4 :
- aggiunte funzioni lua EgtSetVal e EgtGetVal (imposto e leggo su stringa Key=Val) - aggiunta funzione lua EgtSimulate (simulazione in cieco per verifica collisioni e corse) - aggiunte funzioni ExeSetEnableUI e ExeGetEnableUI per disabilitare e riabilitare aggiornamenti interfaccia utente.
This commit is contained in:
+31
-5
@@ -47,6 +47,7 @@ static int s_nKeyType = KEY_LOCK_TYPE_ANY ;
|
||||
static int s_nKeyExpDays = 0 ;
|
||||
static int s_nKeyOptExpDays = 0 ;
|
||||
static string s_sIniFile ;
|
||||
static bool s_bEnableUI = true ;
|
||||
static pfProcEvents s_pFunProcEvents = nullptr ;
|
||||
static pfOutText s_pFunOutText = nullptr ;
|
||||
static HWND s_hMainWnd = nullptr ;
|
||||
@@ -61,6 +62,10 @@ ExeInit( int nDebug, const string& sLogFile, const string& sLogMsg)
|
||||
// cancello eventuale vecchio logger
|
||||
if ( s_pGenLog != nullptr)
|
||||
delete s_pGenLog ;
|
||||
// cancello riferimenti a funzioni installate
|
||||
s_pFunProcEvents = nullptr ;
|
||||
s_pFunOutText = nullptr ;
|
||||
s_bEnableUI = true ;
|
||||
|
||||
// assegno il livello di debug
|
||||
s_nDebugLev = max( nDebug, 0) ;
|
||||
@@ -154,6 +159,7 @@ ExeExit( void)
|
||||
// cancello riferimenti a funzioni installate
|
||||
s_pFunProcEvents = nullptr ;
|
||||
s_pFunOutText = nullptr ;
|
||||
s_bEnableUI = true ;
|
||||
|
||||
// fine programma
|
||||
LOG_DATETIME( s_pGenLog, " Exit")
|
||||
@@ -437,10 +443,30 @@ ExeGetMemoryInfo( string& sMem)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeOutLog( const string& sMsg)
|
||||
ExeOutLog( const string& sMsg, int nDebugLevel)
|
||||
{
|
||||
LOG_INFO( s_pGenLog, sMsg.c_str())
|
||||
return ( s_pGenLog != nullptr) ;
|
||||
if ( s_pGenLog == nullptr)
|
||||
return false ;
|
||||
if ( nDebugLevel == 0)
|
||||
LOG_INFO( s_pGenLog, sMsg.c_str())
|
||||
else if ( ExeGetDebugLevel() >= nDebugLevel)
|
||||
LOG_DBG_INFO( s_pGenLog, sMsg.c_str())
|
||||
return true ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSetEnableUI( bool bEnableUI)
|
||||
{
|
||||
s_bEnableUI = bEnableUI ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeGetEnableUI( void)
|
||||
{
|
||||
return s_bEnableUI ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -456,7 +482,7 @@ ExeSetProcessEvents( pfProcEvents pFun)
|
||||
int
|
||||
ExeProcessEvents( int nProg, int nPause)
|
||||
{
|
||||
if ( s_pFunProcEvents != nullptr)
|
||||
if ( s_pFunProcEvents != nullptr && s_bEnableUI)
|
||||
return s_pFunProcEvents( nProg, nPause) ;
|
||||
else
|
||||
return 0 ;
|
||||
@@ -474,7 +500,7 @@ ExeSetOutText( pfOutText pFun)
|
||||
bool
|
||||
ExeOutText( const string& sText)
|
||||
{
|
||||
if ( s_pFunOutText != nullptr)
|
||||
if ( s_pFunOutText != nullptr && s_bEnableUI)
|
||||
return s_pFunOutText( sText) ;
|
||||
else
|
||||
return false ;
|
||||
|
||||
+68
-1
@@ -2676,7 +2676,7 @@ ExeSimExit( void)
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Generazione e Stima T&L
|
||||
// Generazione, Stima T&L e Simulazione
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeGenerate( const string& sCncFile, const string& sInfo)
|
||||
@@ -2732,6 +2732,73 @@ ExeEstimate( const string& sEstFile, const string& sInfo)
|
||||
return pMachMgr->Estimate( sMyEstFile, sInfo) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool
|
||||
ExeSimulate( int& nErr, std::string& sError)
|
||||
{
|
||||
IMachMgr* pMachMgr = GetCurrMachMgr() ;
|
||||
VERIFY_MACHMGR( pMachMgr, false)
|
||||
// inizializzo lo stato
|
||||
bool bContinue = true ;
|
||||
nErr = SHE_NONE ;
|
||||
sError = "" ;
|
||||
// disabilito UI
|
||||
ExeSetEnableUI( false) ;
|
||||
// avvio simulazione
|
||||
if ( ! pMachMgr->SimInit() || ! pMachMgr->SimStart( true) || ! pMachMgr->SimStart( false)) {
|
||||
// inutile continuare con simulazione se avvio non riuscito
|
||||
bContinue = false ;
|
||||
// assegno il codice di errore
|
||||
nErr = SHE_INIT ;
|
||||
// assegno stringa di errore
|
||||
sError = "Starting simulation failed" ;
|
||||
ExeOutLog( sError, 1) ;
|
||||
}
|
||||
pMachMgr->SimSetStep( 50) ;
|
||||
// ciclo di simulazione
|
||||
while ( bContinue) {
|
||||
int nStat ;
|
||||
bContinue = pMachMgr->SimMove( nStat) ;
|
||||
// gestione errori
|
||||
if ( nStat == MCH_SIM_OUTSTROKE) {
|
||||
// assegno il codice di errore
|
||||
nErr = SHE_OUTSTROKE ;
|
||||
// recupero stringa di errore
|
||||
sError = pMachMgr->GetOutstrokeInfo( ExeUiUnitsAreMM()) ;
|
||||
ExeOutLog( sError, 1) ;
|
||||
}
|
||||
else if ( nStat == MCH_SIM_DIR_ERR) {
|
||||
// assegno il codice di errore
|
||||
nErr = SHE_DIR_ERR ;
|
||||
// assegno stringa di errore
|
||||
sError = "Tool direction unreachable" ;
|
||||
ExeOutLog( sError, 1) ;
|
||||
}
|
||||
else if ( nStat == MCH_SIM_COLLISION) {
|
||||
// assegno il codice di errore
|
||||
nErr = SHE_COLLISION ;
|
||||
// recupero stringa di errore
|
||||
if ( pMachMgr->GetLastErrorId() != 0)
|
||||
sError = pMachMgr->GetLastErrorString() ;
|
||||
else
|
||||
sError = "Found collision head-part" ;
|
||||
ExeOutLog( sError, 1) ;
|
||||
}
|
||||
else if ( nStat == MCH_SIM_ERR) {
|
||||
// assegno il codice di errore
|
||||
nErr = SHE_GENERAL ;
|
||||
// assegno stringa di errore
|
||||
sError = "General failure (contact supplier)" ;
|
||||
ExeOutLog( sError, 1) ;
|
||||
}
|
||||
}
|
||||
// terminazione simulazione
|
||||
pMachMgr->SimExit() ;
|
||||
// riabilito UI
|
||||
ExeSetEnableUI( true) ;
|
||||
return ( nErr == 0) ;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Machine Calc
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
+3
-2
@@ -193,8 +193,9 @@ ExeDraw( void)
|
||||
{
|
||||
GseContext* pGseCtx = GetCurrGseContext() ;
|
||||
VERIFY_CTX_SCENE( pGseCtx, false)
|
||||
// eseguo disegno
|
||||
pGseCtx->m_pScene->Draw() ;
|
||||
// se abilitato, eseguo disegno
|
||||
if ( ExeGetEnableUI())
|
||||
pGseCtx->m_pScene->Draw() ;
|
||||
// valido la finestra disegnata
|
||||
ValidateRgn( pGseCtx->m_hWnd, NULL) ;
|
||||
return true ;
|
||||
|
||||
Binary file not shown.
+2
-2
@@ -1,7 +1,7 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2014-2014
|
||||
// EgalTech 2014-2019
|
||||
//----------------------------------------------------------------------------
|
||||
// File : GseContext.h Data : 01.09.14 Versione : 1.5i1
|
||||
// File : GseContext.h Data : 18.07.19 Versione : 2.1g4
|
||||
// Contenuto : Dichiarazioni per contesti GSE ( Geometria, Scena, Esecuzione).
|
||||
//
|
||||
//
|
||||
|
||||
+141
-13
@@ -20,9 +20,11 @@
|
||||
#include "resource.h"
|
||||
#include "/EgtDev/Include/ExeExecutor.h"
|
||||
#include "/EgtDev/Include/EGkLuaAux.h"
|
||||
#include "/EgtDev/Include/EGkStringUtils3d.h"
|
||||
#include "/EgtDev/Include/EGnStringUtils.h"
|
||||
#include "/EgtDev/Include/EGnFileUtils.h"
|
||||
#include "/EgtDev/Include/EGnFileCompare.h"
|
||||
#include "/EgtDev/Include/EGnStringKeyVal.h"
|
||||
#include "/EgtDev/Include/EgtPerfCounter.h"
|
||||
#include "/EgtDev/Include/EgtIniFile.h"
|
||||
#include "/EgtDev/Include/EgtStringConverter.h"
|
||||
@@ -87,14 +89,16 @@ LuaPause( lua_State* L)
|
||||
int nTime ;
|
||||
LuaCheckParam( L, 1, nTime)
|
||||
LuaClearStack( L) ;
|
||||
// controllo la durata della pausa e la eseguo
|
||||
const int MIN_TIME = 0 ;
|
||||
const int MAX_TIME = 10000 ;
|
||||
if ( nTime < MIN_TIME)
|
||||
nTime = MIN_TIME ;
|
||||
else if ( nTime > MAX_TIME)
|
||||
nTime = MAX_TIME ;
|
||||
Sleep( nTime) ;
|
||||
// se abilitata UI, controllo la durata della pausa e la eseguo
|
||||
if ( ExeGetEnableUI()) {
|
||||
const int MIN_TIME = 0 ;
|
||||
const int MAX_TIME = 10000 ;
|
||||
if ( nTime < MIN_TIME)
|
||||
nTime = MIN_TIME ;
|
||||
else if ( nTime > MAX_TIME)
|
||||
nTime = MAX_TIME ;
|
||||
Sleep( nTime) ;
|
||||
}
|
||||
// restituisco il risultato
|
||||
LuaSetParam( L, true) ;
|
||||
return 1 ;
|
||||
@@ -188,6 +192,131 @@ LuaSplitStringPlus( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSetVal( lua_State* L)
|
||||
{
|
||||
// 2 parametri : Key, bVal|nVal|dVal|sVal|vtVal|ptVal|b3Val|frVal
|
||||
int nId ;
|
||||
LuaCheckParam( L, 1, nId)
|
||||
string sKey ;
|
||||
LuaCheckParam( L, 2, sKey)
|
||||
bool bOk = false ;
|
||||
string sNotes = "" ;
|
||||
switch ( lua_type( L, 3)) {
|
||||
case LUA_TBOOLEAN :
|
||||
{ bool bVal ;
|
||||
LuaGetParam( L, 3, bVal) ;
|
||||
LuaClearStack( L) ;
|
||||
bOk = SetValInNotes( sKey, bVal, sNotes) ;
|
||||
} break ;
|
||||
case LUA_TNUMBER :
|
||||
{ double dVal ;
|
||||
LuaGetParam( L, 3, dVal) ;
|
||||
LuaClearStack( L) ;
|
||||
bOk = SetValInNotes( sKey, dVal, sNotes) ;
|
||||
} break ;
|
||||
case LUA_TSTRING :
|
||||
{ string sVal ;
|
||||
LuaGetParam( L, 3, sVal) ;
|
||||
LuaClearStack( L) ;
|
||||
bOk = SetValInNotes( sKey, (const string&) sVal, sNotes) ;
|
||||
} break ;
|
||||
case LUA_TTABLE :
|
||||
{ Frame3d frVal ;
|
||||
BBox3d b3Val ;
|
||||
Vector3d vtVal ; // va bene anche per Point3d
|
||||
if ( LuaGetParam( L, 3, frVal)) {
|
||||
LuaClearStack( L) ;
|
||||
bOk = SetValInNotes( sKey, frVal, sNotes) ;
|
||||
}
|
||||
else if ( LuaGetParam( L, 3, b3Val)) {
|
||||
LuaClearStack( L) ;
|
||||
bOk = SetValInNotes( sKey, b3Val, sNotes) ;
|
||||
}
|
||||
else if ( LuaGetParam( L, 3, vtVal)) {
|
||||
LuaClearStack( L) ;
|
||||
bOk = SetValInNotes( sKey, vtVal, sNotes) ;
|
||||
}
|
||||
} break ;
|
||||
}
|
||||
// restituisco il risultato
|
||||
LuaSetParam( L, sNotes) ;
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaGetVal( lua_State* L)
|
||||
{
|
||||
// 2 o 3 parametri : String, Key, sType
|
||||
string sVal ;
|
||||
LuaCheckParam( L, 1, sVal)
|
||||
string sKey ;
|
||||
LuaCheckParam( L, 2, sKey)
|
||||
string sType = "s" ;
|
||||
LuaGetParam( L, 3, sType) ;
|
||||
LuaClearStack( L) ;
|
||||
// recupero l'info
|
||||
if ( sType == "b" || sType == "B") {
|
||||
bool bVal ;
|
||||
if ( GetVal( sVal, sKey, bVal))
|
||||
LuaSetParam( L, bVal) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
}
|
||||
else if ( sType == "i" || sType == "I") {
|
||||
int nVal ;
|
||||
if ( GetVal( sVal, sKey, nVal))
|
||||
LuaSetParam( L, nVal) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
}
|
||||
else if ( sType == "d" || sType == "D") {
|
||||
double dVal ;
|
||||
if ( GetVal( sVal, sKey, dVal))
|
||||
LuaSetParam( L, dVal) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
}
|
||||
else if ( sType == "v" || sType == "V") {
|
||||
Vector3d vtVal ;
|
||||
if ( GetVal( sVal, sKey, vtVal))
|
||||
LuaSetParam( L, vtVal) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
}
|
||||
else if ( sType == "p" || sType == "P") {
|
||||
Point3d ptVal ;
|
||||
if ( GetVal( sVal, sKey, ptVal))
|
||||
LuaSetParam( L, ptVal) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
}
|
||||
else if ( sType == "x" || sType == "X") {
|
||||
BBox3d b3Val ;
|
||||
if ( GetVal( sVal, sKey, b3Val))
|
||||
LuaSetParam( L, b3Val) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
}
|
||||
else if ( sType == "f" || sType == "F") {
|
||||
Frame3d frVal ;
|
||||
if ( GetVal( sVal, sKey, frVal))
|
||||
LuaSetParam( L, frVal) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
}
|
||||
else { // "s" "S"
|
||||
string sInfo ;
|
||||
if ( GetVal( sVal, sKey, sInfo))
|
||||
LuaSetParam( L, sInfo) ;
|
||||
else
|
||||
LuaSetParam( L) ;
|
||||
}
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaExecTsc( lua_State* L)
|
||||
@@ -270,17 +399,14 @@ LuaGetDebugLevel( lua_State* L)
|
||||
static int
|
||||
LuaOutLog( lua_State* L)
|
||||
{
|
||||
// 1 o 2 parametri : stringa da emettere [, DebugLevel]
|
||||
// 1 o 2 parametri : stringa da emettere [, DebugLevel = 0]
|
||||
string sOut ;
|
||||
LuaCheckParam( L, 1, sOut)
|
||||
int nDbgLev = 0 ;
|
||||
LuaGetParam( L, 2, nDbgLev) ;
|
||||
LuaClearStack( L) ;
|
||||
// accodo il messaggio nel file di log
|
||||
if ( nDbgLev == 0)
|
||||
LOG_INFO( GetLogger(), sOut.c_str())
|
||||
else if ( ExeGetDebugLevel() >= nDbgLev)
|
||||
LOG_DBG_INFO( GetLogger(), sOut.c_str())
|
||||
ExeOutLog( sOut, nDbgLev) ;
|
||||
// non c'è risultato
|
||||
return 0 ;
|
||||
}
|
||||
@@ -791,6 +917,8 @@ LuaInstallGeneral( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtNumToString", LuaNumToString) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSplitString", LuaSplitString) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSplitStringPlus", LuaSplitStringPlus) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSetVal", LuaSetVal) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetVal", LuaGetVal) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtExecTsc", LuaExecTsc) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtExecTscLine", LuaExecTscLine) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSetTscVar", LuaSetTscVar) ;
|
||||
|
||||
+19
-1
@@ -2914,6 +2914,23 @@ LuaEstimate( lua_State* L)
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
static int
|
||||
LuaSimulate( lua_State* L)
|
||||
{
|
||||
// nessun parametro
|
||||
LuaClearStack( L) ;
|
||||
// eseguo la simulazione
|
||||
int nErr ;
|
||||
string sErr ;
|
||||
bool bOk = ExeSimulate( nErr, sErr) ;
|
||||
// restituisco il risultato
|
||||
LuaSetParam( L, bOk) ;
|
||||
LuaSetParam( L, nErr) ;
|
||||
LuaSetParam( L, sErr) ;
|
||||
return 3 ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// Machine Calc
|
||||
//-------------------------------------------------------------------------------
|
||||
@@ -3693,9 +3710,10 @@ LuaInstallMachMgr( LuaMgr& luaMgr)
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSimGetOperationInfo", LuaSimGetOperationInfo) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSimGetMoveInfo", LuaSimGetMoveInfo) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSimExit", LuaSimExit) ;
|
||||
// Generation & T&L estimation
|
||||
// Generation, T&L estimation e Simulazione
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGenerate", LuaGenerate) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtEstimate", LuaEstimate) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtSimulate", LuaSimulate) ;
|
||||
// Machine
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetBaseId", LuaGetBaseId) ;
|
||||
bOk = bOk && luaMgr.RegisterFunction( "EgtGetTableId", LuaGetTableId) ;
|
||||
|
||||
Reference in New Issue
Block a user