diff --git a/Estimator.cpp b/Estimator.cpp index 4e37319..0629fa5 100644 --- a/Estimator.cpp +++ b/Estimator.cpp @@ -15,9 +15,12 @@ #include "stdafx.h" #include "DllMain.h" #include "Estimator.h" -#include "Machine.h" +#include "MachMgr.h" #include "OutputConst.h" #include "/EgtDev/Include/EGnFileUtils.h" +#include "/EgtDev/Include/EGnGetKeyData.h" +#include "/EgtDev/Include/EgtKeyCodes.h" +#include "/EgtDev/Include/SELkKeyProc.h" using namespace std ; @@ -45,23 +48,75 @@ Estimator::Init( MachMgr* pMchMgr) bool Estimator::Run( const string& sCncFile, const string& sInfo) { - // emetto info di log - { string sOut = "Estimator Run : " + sCncFile ; - LOG_INFO( GetEMkLogger(), sOut.c_str()) ; } + // Controllo della licenza + unsigned int nOpt1, nOpt2 ; + int nOptExpDays ; + int nRet = GetEGnKeyOptions( KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV, + nOpt1, nOpt2, nOptExpDays) ; + if ( ! GetEMkNetHwKey()) + nRet = GetKeyOptions( GetEMkKey(), KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV, + nOpt1, nOpt2, nOptExpDays) ; + + // Verifica della abilitazione + bool bMinTime = false ; + if ( nOptExpDays >= GetMinDay()) + bMinTime = true ; + bool bCurrTime = false ; + if ( nOptExpDays >= GetCurrDay()) + bCurrTime = true ; + bool bKey = false ; + if ( nRet == KEY_OK) + bKey = true ; + bool bAdvMach = false ; + if ( ( nOpt1 & KEYOPT_EMK_ADV) == 1) + bAdvMach = true ; + + // Esecuzione + if ( bMinTime && bCurrTime && bKey) { + // se non previste lavorazioni avanzate, verifico la loro assenza + if ( ! bAdvMach) { + int nOpId = m_pMchMgr->GetFirstActiveOperation() ; + while ( nOpId != GDB_ID_NULL) { + int nType = m_pMchMgr->GetOperationType( nOpId) ; + if ( nType == OPER_SURFROUGHING || nType == OPER_SURFFINISHING || nType == OPER_FIVEAXISMILLING) { + m_pMchMgr->SetLastError( 1001, "ADVANCED_MACH_OFF") ; + std::string sErr = "Warning on Key (MKC/AMO)" ; + LOG_ERROR( GetEMkLogger(), sErr.c_str()) ; + return false ; + } + nOpId = m_pMchMgr->GetNextActiveOperation( nOpId) ; + } + } + + // emetto info di log + { string sOut = "Estimator Run : " + sCncFile ; + LOG_INFO( GetEMkLogger(), sOut.c_str()) ; } + + // cancello l'eventuale file di uscita (e anche il file errore) + EraseFile( sCncFile) ; + string sErrFile = ChangeFileExtension( sCncFile, ERR_EXT) ; + EraseFile( sErrFile) ; + + // lancio il processore + bool bOk = Processor::Run( sCncFile, sInfo) ; + + // in caso di errore rinomino il file di output + if ( ! bOk) + RenameFile( sCncFile, sErrFile) ; + + return bOk ; + } // cancello l'eventuale file di uscita (e anche il file errore) EraseFile( sCncFile) ; string sErrFile = ChangeFileExtension( sCncFile, ERR_EXT) ; EraseFile( sErrFile) ; - // lancio il processore - bool bOk = Processor::Run( sCncFile, sInfo) ; - - // in caso di errore rinomino il file di output - if ( ! bOk) - RenameFile( sCncFile, sErrFile) ; - - return bOk ; + // Generazione non abilitata + m_pMchMgr->SetLastError( 1000, "NC_OFF") ; + std::string sErr = "Warning on Key (MKC/KYO)" ; + LOG_ERROR( GetEMkLogger(), sErr.c_str()) ; + return false ; } //---------------------------------------------------------------------------- diff --git a/Generator.cpp b/Generator.cpp index 3dc0a58..85d4e4a 100644 --- a/Generator.cpp +++ b/Generator.cpp @@ -17,9 +17,10 @@ #include "Generator.h" #include "MachMgr.h" #include "OutputConst.h" -#include "/EgtDev/Include/EMkDllMain.h" #include "/EgtDev/Include/EGnFileUtils.h" #include "/EgtDev/Include/EGnGetKeyData.h" +#include "/EgtDev/Include/EgtKeyCodes.h" +#include "/EgtDev/Include/SELkKeyProc.h" using namespace std ; @@ -66,12 +67,30 @@ Generator::Run( const string& sCncFile, const string& sInfo) bool bKey = false ; if ( nRet == KEY_OK) bKey = true ; - bool bOption = false ; - if ( ( nOpt1 & KEYOPT_EMK_NC_OFF) == 0) - bOption = true ; + bool bNcOff = false ; + if ( ( nOpt1 & KEYOPT_EMK_NC_OFF) == 1) + bNcOff = true ; + bool bAdvMach = false ; + if ( ( nOpt1 & KEYOPT_EMK_ADV) == 1) + bAdvMach = true ; // Esecuzione - if ( bMinTime && bCurrTime && bKey && bOption) { + if ( bMinTime && bCurrTime && bKey && ! bNcOff) { + + // se non previste lavorazioni avanzate, verifico la loro assenza + if ( ! bAdvMach) { + int nOpId = m_pMchMgr->GetFirstActiveOperation() ; + while ( nOpId != GDB_ID_NULL) { + int nType = m_pMchMgr->GetOperationType( nOpId) ; + if ( nType == OPER_SURFROUGHING || nType == OPER_SURFFINISHING || nType == OPER_FIVEAXISMILLING) { + m_pMchMgr->SetLastError( 1001, "ADVANCED_MACH_OFF") ; + std::string sErr = "Warning on Key (MKC/AMO)" ; + LOG_ERROR( GetEMkLogger(), sErr.c_str()) ; + return false ; + } + nOpId = m_pMchMgr->GetNextActiveOperation( nOpId) ; + } + } // emetto info di log { string sOut = "Generator Run : " + sCncFile ; @@ -99,7 +118,7 @@ Generator::Run( const string& sCncFile, const string& sInfo) // Generazione non abilitata m_pMchMgr->SetLastError( 1000, "NC_OFF") ; - std::string sErr = "Warning on Key (MKC/NCO)" ; + std::string sErr = ( bNcOff ? "Warning on Key (MKC/NCO)" : "Warning on Key (MKC/KYO)") ; LOG_ERROR( GetEMkLogger(), sErr.c_str()) ; return false ; } diff --git a/SimulatorMP.cpp b/SimulatorMP.cpp index 9b6170f..80bef6a 100644 --- a/SimulatorMP.cpp +++ b/SimulatorMP.cpp @@ -34,8 +34,11 @@ #include "/EgtDev/Include/EXeConst.h" #include "/EgtDev/Include/EMkToolConst.h" #include "/EgtDev/Include/EMkOperationConst.h" +#include "/EgtDev/Include/EGnGetKeyData.h" #include "/EgtDev/Include/EgtPerfCounter.h" #include "/EgtDev/Include/EgtNumUtils.h" +#include "/EgtDev/Include/EgtKeyCodes.h" +#include "/EgtDev/Include/SELkKeyProc.h" using namespace std ; @@ -145,6 +148,51 @@ SimulatorMP::Start( bool bFirst) m_pMchMgr->ResetLastError() ; m_pMchMgr->ResetWarnings() ; + // Se appena entrati, verifico abilitazioni + if ( m_nStatus == SIS_INITIALIZED) { + // Controllo della licenza + unsigned int nOpt1, nOpt2 ; + int nOptExpDays ; + int nRet = GetEGnKeyOptions( KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV, + nOpt1, nOpt2, nOptExpDays) ; + if ( ! GetEMkNetHwKey()) + nRet = GetKeyOptions( GetEMkKey(), KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV, + nOpt1, nOpt2, nOptExpDays) ; + + // Verifica della abilitazione + bool bMinTime = false ; + if ( nOptExpDays >= GetMinDay()) + bMinTime = true ; + bool bCurrTime = false ; + if ( nOptExpDays >= GetCurrDay()) + bCurrTime = true ; + bool bKey = false ; + if ( nRet == KEY_OK) + bKey = true ; + bool bAdvMach = false ; + if ( ( nOpt1 & KEYOPT_EMK_ADV) == 1) + bAdvMach = true ; + if ( ! bMinTime || ! bCurrTime || ! bKey) { + m_pMchMgr->SetLastError( 1000, "NC_OFF") ; + std::string sErr = "Warning on Key (MKC/KYO)" ; + LOG_ERROR( GetEMkLogger(), sErr.c_str()) ; + return false ; + } + if ( ! bAdvMach) { + int nOpId = m_pMchMgr->GetFirstActiveOperation() ; + while ( nOpId != GDB_ID_NULL) { + int nType = m_pMchMgr->GetOperationType( nOpId) ; + if ( nType == OPER_SURFROUGHING || nType == OPER_SURFFINISHING || nType == OPER_FIVEAXISMILLING) { + m_pMchMgr->SetLastError( 1001, "ADVANCED_MACH_OFF") ; + std::string sErr = "Warning on Key (MKC/AMO)" ; + LOG_ERROR( GetEMkLogger(), sErr.c_str()) ; + return false ; + } + nOpId = m_pMchMgr->GetNextActiveOperation( nOpId) ; + } + } + } + bool bOk = true ; // Se appena entrati in simulazione diff --git a/SimulatorSP.cpp b/SimulatorSP.cpp index a644e17..9030ea1 100644 --- a/SimulatorSP.cpp +++ b/SimulatorSP.cpp @@ -35,8 +35,11 @@ #include "/EgtDev/Include/EXeConst.h" #include "/EgtDev/Include/EMkToolConst.h" #include "/EgtDev/Include/EMkOperationConst.h" +#include "/EgtDev/Include/EGnGetKeyData.h" #include "/EgtDev/Include/EgtPerfCounter.h" #include "/EgtDev/Include/EgtNumUtils.h" +#include "/EgtDev/Include/EgtKeyCodes.h" +#include "/EgtDev/Include/SELkKeyProc.h" using namespace std ; @@ -142,6 +145,51 @@ SimulatorSP::Start( bool bFirst) m_pMchMgr->ResetLastError() ; m_pMchMgr->ResetWarnings() ; + // Se appena entrati, verifico abilitazioni + if ( m_nStatus == SIS_INITIALIZED) { + // Controllo della licenza + unsigned int nOpt1, nOpt2 ; + int nOptExpDays ; + int nRet = GetEGnKeyOptions( KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV, + nOpt1, nOpt2, nOptExpDays) ; + if ( ! GetEMkNetHwKey()) + nRet = GetKeyOptions( GetEMkKey(), KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV, + nOpt1, nOpt2, nOptExpDays) ; + + // Verifica della abilitazione + bool bMinTime = false ; + if ( nOptExpDays >= GetMinDay()) + bMinTime = true ; + bool bCurrTime = false ; + if ( nOptExpDays >= GetCurrDay()) + bCurrTime = true ; + bool bKey = false ; + if ( nRet == KEY_OK) + bKey = true ; + bool bAdvMach = false ; + if ( ( nOpt1 & KEYOPT_EMK_ADV) == 1) + bAdvMach = true ; + if ( ! bMinTime || ! bCurrTime || ! bKey) { + m_pMchMgr->SetLastError( 1000, "NC_OFF") ; + std::string sErr = "Warning on Key (MKC/KYO)" ; + LOG_ERROR( GetEMkLogger(), sErr.c_str()) ; + return false ; + } + if ( ! bAdvMach) { + int nOpId = m_pMchMgr->GetFirstActiveOperation() ; + while ( nOpId != GDB_ID_NULL) { + int nType = m_pMchMgr->GetOperationType( nOpId) ; + if ( nType == OPER_SURFROUGHING || nType == OPER_SURFFINISHING || nType == OPER_FIVEAXISMILLING) { + m_pMchMgr->SetLastError( 1001, "ADVANCED_MACH_OFF") ; + std::string sErr = "Warning on Key (MKC/AMO)" ; + LOG_ERROR( GetEMkLogger(), sErr.c_str()) ; + return false ; + } + nOpId = m_pMchMgr->GetNextActiveOperation( nOpId) ; + } + } + } + bool bOk = true ; // Se appena entrati in simulazione