diff --git a/OutputConst.h b/OutputConst.h index 01d6663..69d62eb 100644 --- a/OutputConst.h +++ b/OutputConst.h @@ -140,6 +140,8 @@ static const std::string GVAR_ANN = ".ANn" ; // (string) nome del N static const std::string GVAR_VMILL = ".VMILL" ; // (int) identificativo Zmap attivo static const std::string GVAR_SIM1ST = ".SIM1ST" ; // (bool) flag inizio simulazione static const std::string GVAR_SIMSTEP = ".SIMSTEP" ; // (num) step di movimento durante la simulazione +static const std::string GVAR_SIMUISTAT = ".SIMUISTAT" ; // (num) stato simulazione imposto da utente + // Funzioni generazione static const std::string ON_START = "OnStart" ; diff --git a/Simulator.cpp b/Simulator.cpp index 644e0f8..e890e8e 100644 --- a/Simulator.cpp +++ b/Simulator.cpp @@ -33,7 +33,10 @@ using namespace std ; // 1001 = "Error with setup : xxx" //---------------------------------------------------------------------------- -const double COEFF_LIM = 0.999 ; +static const double MIN_STEP = 1.0 ; +static const double MAX_STEP = 100.0 ; +static const double MID_STEP = 50.0 ; +static const double COEFF_LIM = 0.999 ; //---------------------------------------------------------------------------- Simulator::Simulator( void) @@ -41,7 +44,8 @@ Simulator::Simulator( void) m_pMchMgr = nullptr ; m_pGeomDB = nullptr ; m_pMachine = nullptr ; - m_dStep = 5.0 ; + m_dStep = MID_STEP ; + m_nUiStatus = MCH_UISIM_NULL ; m_nOpId = GDB_ID_NULL ; m_nOpInd = 0 ; m_nCLPathId = GDB_ID_NULL ; @@ -329,8 +333,6 @@ Simulator::GetMoveInfo( int& nGmove, double& dFeed) const bool Simulator::SetStep( double dStep) { - const double MIN_STEP = 1.0 ; - const double MAX_STEP = 100.0 ; m_dStep = Clamp( dStep, MIN_STEP, MAX_STEP) ; // imposto step per movimenti gestiti nelle macro di simulazione m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_SIMSTEP, m_dStep) ; @@ -343,7 +345,7 @@ Simulator::SetUiStatus( int nUiStatus) { m_nUiStatus = nUiStatus ; // imposto stato simulatore a livello utente per movimenti gestiti nelle macro di simulazione - m_pMachine->LuaSetGlobVar( GLOB_VAR + ".SIMUISTAT", m_nUiStatus) ; + m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_SIMUISTAT, m_nUiStatus) ; return true ; } @@ -865,8 +867,8 @@ Simulator::ManageMove( int& nStatus) if ( Stopped()) return true ; dCurrMove += dMove ; - // se non raggiunto lo step - if ( m_dCoeff > COEFF_LIM && dCurrMove < 0.9 * m_dStep) { + // se modalità play e fine entità e non raggiunta la lunghezza di movimento voluto + if ( m_nUiStatus == MCH_UISIM_PLAY && nStatus == MCH_SIM_END_STEP && dCurrMove < 0.75 * m_dStep) { // recupero una nuova entità m_nEntId = m_pGeomDB->GetNext( m_nEntId) ; m_dCoeff = 0 ; @@ -1058,7 +1060,7 @@ Simulator::ManageSingleMove( int& nStatus, double& dMove) } } } - // Altrimenti sto muovendomi all'interno dello step + // Altrimenti sto muovendomi all'interno dell'entità else nStatus = MCH_SIM_OK ;