From 716ffccd160bda82efb7d165d67c64edd17edfd3 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Wed, 28 Feb 2018 18:05:56 +0000 Subject: [PATCH] EgtMachKernel 1.9c2 : - in simulazione aggiunti eventi OnSimulationStart e OnSimulationEnd. --- EgtMachKernel.rc | Bin 11774 -> 11774 bytes OutputConst.h | 3 +++ Simulator.cpp | 31 ++++++++++++++++++++++++++++++- Simulator.h | 2 ++ 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/EgtMachKernel.rc b/EgtMachKernel.rc index 0be1605bcd6cbeeb7933c1dbfdc620971b4f528b..b16ce8d5c9fe6a4384ed6bdc847aebfa2cc25cf4 100644 GIT binary patch delta 97 zcmewt{V#gMFE&P_&A-`fnHh~HKa|wnoW?bQ1uSxrY4Qod0+^@}R1`^_2jk{d(jGv4 NK<#LXK~l;gTmU8!BZvS1 delta 97 zcmewt{V#gMFE&QQ&A-`fnHdcyKa|wnoW?bQ1uSxrY4Qod0+^@}R1`^_2jk{d(jGv4 NK<#LXK~l;gTmU3rBY*$^ diff --git a/OutputConst.h b/OutputConst.h index bb6a53b..c82191d 100644 --- a/OutputConst.h +++ b/OutputConst.h @@ -128,6 +128,7 @@ static const std::string GVAR_AUXAXES = ".AuxAxes" ; // (int) numero ass static const std::string GVAR_AN = ".AN" ; // (num) valore del N-esimo asse ausiliario per simulazione static const std::string GVAR_ANN = ".ANn" ; // (string) nome del N-esimo asse ausiliario per simulazione static const std::string GVAR_VMILL = ".VMILL" ; // (int) identificativo Zmap attivo +static const std::string GVAR_SIM1ST = ".SIM1ST" ; // (bool) flag inizio simulazione // Funzioni generazione static const std::string ON_START = "OnStart" ; @@ -152,6 +153,8 @@ static const std::string ON_RAPID = "OnRapid" ; static const std::string ON_LINEAR = "OnLinear" ; static const std::string ON_ARC = "OnArc" ; // Funzioni simulazione +static const std::string ON_SIMUL_START = "OnSimulStart" ; +static const std::string ON_SIMUL_END = "OnSimulEnd" ; static const std::string ON_SIMUL_DISPOSITION_STARTING = "OnSimulDispositionStarting" ; static const std::string ON_SIMUL_DISPOSITION_START = "OnSimulDispositionStart" ; static const std::string ON_SIMUL_DISPOSITION_END = "OnSimulDispositionEnd" ; diff --git a/Simulator.cpp b/Simulator.cpp index a5630e1..f4ac04f 100644 --- a/Simulator.cpp +++ b/Simulator.cpp @@ -115,6 +115,10 @@ Simulator::Start( bool bFirst) if ( ! m_pMachine->LuaCreateGlobTable( GLOB_VAR)) bOk = false ; + // Richiamo funzione su avvio simulazione + if ( ! OnStart( bFirst)) + bOk = false ; + // Arrivo alla preparazione per la prima lavorazione int nStatus ; if ( ! FindAndManageOperationStart( true, bFirst, nStatus)) @@ -185,6 +189,7 @@ Simulator::Move( int& nStatus) return false ; // se non ce ne sono altre, sono alla fine if ( m_nOpId == GDB_ID_NULL) { + OnEnd() ; nStatus = MCH_SIM_END ; return false ; } @@ -1002,12 +1007,36 @@ Simulator::ExecVmillOnLine( const Point3d& ptHi, const Vector3d& vtHi, const Vec return pVZM->MillingStep( ptHiL, vtHiL, vtAiL, ptHfL, vtHfL, vtAfL) ; } +//---------------------------------------------------------------------------- +bool +Simulator::OnStart( bool bFirst) +{ + // assegno flag inizio simulazione + bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_SIM1ST, bFirst) ; + // verifico esistenza funzione + if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_START)) + return true ; + // chiamo la funzione di inizio simulazione + bOk = bOk && m_pMachine->LuaCallFunction( ON_SIMUL_START) ; + return bOk ; +} + +//---------------------------------------------------------------------------- +bool +Simulator::OnEnd( void) +{ + // verifico esistenza funzione + if ( ! m_pMachine->LuaExistsFunction( ON_SIMUL_END)) + return true ; + // chiamo la funzione di fine simulazione + return m_pMachine->LuaCallFunction( ON_SIMUL_END) ; +} + //---------------------------------------------------------------------------- bool Simulator::OnDispositionStarting( int nOpId, int nOpInd, int nPhase, const string& sTable, const Point3d& ptOri1, bool bEmpty, bool bSomeByHand) { - // assegno identificativo e indice disposizione bool bOk = m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_DISPID, nOpId) ; bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_DISPIND, nOpInd) ; // assegno nuovo indice di fase diff --git a/Simulator.h b/Simulator.h index c8bd330..8d4d7f7 100644 --- a/Simulator.h +++ b/Simulator.h @@ -56,6 +56,8 @@ class Simulator bool GetHeadCurrPosDirAux( Point3d& ptH, Vector3d& vtH, Vector3d& vtA) ; bool ExecVmillOnLine( const Point3d& ptHi, const Vector3d& vtHi, const Vector3d& vtAi, const Frame3d& frVzmI, const Point3d& ptHf, const Vector3d& vtHf, const Vector3d& vtAf, const Frame3d& frVzmF) ; + bool OnStart( bool bFirst) ; + bool OnEnd( void) ; bool OnDispositionStarting( int nOpId, int nOpInd, int nPhase, const std::string& sTable, const Point3d& ptOri1, bool bEmpty, bool bSomeByHand) ; bool OnDispositionStart( int nOpId, int nOpInd, int nPhase,