b74f0d407d
- aggiunta a PostProc la chiamata a OnTableAxisData e a Estimator la chiamata a OnEstimTableAxisData per ogni asse di tavola su quella corrente - modifiche varie a Machine per rendere possibile la modifica precedente - piccolo aggiustamento a inizializzazione di dZConstOverlap.
293 lines
8.9 KiB
C++
293 lines
8.9 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2015-2018
|
|
//----------------------------------------------------------------------------
|
|
// File : Estimator.cpp Data : 28.05.18 Versione : 1.9e6
|
|
// Contenuto : Implementazione della classe Estimator.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 28.10.15 DS Creazione modulo.
|
|
// 26.02.16 DS Aggiunta gestione archi.
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "DllMain.h"
|
|
#include "Estimator.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 ;
|
|
|
|
//----------------------------------------------------------------------------
|
|
static const string ERR_EXT = ".err" ;
|
|
|
|
//----------------------------------------------------------------------------
|
|
Estimator::Estimator( void)
|
|
{
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
Estimator::~Estimator( void)
|
|
{
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Estimator::Init( MachMgr* pMchMgr)
|
|
{
|
|
return Processor::Init( pMchMgr) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Estimator::Run( const string& sCncFile, const string& sInfo)
|
|
{
|
|
// 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) != 0)
|
|
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) ;
|
|
|
|
// 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 ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Estimator::CallOnStart( void)
|
|
{
|
|
return m_pMachine->LuaCallFunction( ON_ESTIM_START) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Estimator::CallOnEnd( void)
|
|
{
|
|
return m_pMachine->LuaCallFunction( ON_ESTIM_END) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Estimator::CallOnProgramStart( void)
|
|
{
|
|
return m_pMachine->LuaCallFunction( ON_ESTIM_PROGRAM_START) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Estimator::CallOnProgramEnd( void)
|
|
{
|
|
return m_pMachine->LuaCallFunction( ON_ESTIM_PROGRAM_END) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Estimator::CallOnToolData( void)
|
|
{
|
|
if ( ! m_pMachine->LuaExistsFunction( ON_ESTIM_TOOL_DATA))
|
|
return true ;
|
|
return m_pMachine->LuaCallFunction( ON_ESTIM_TOOL_DATA) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Estimator::CallOnDispositionStart( void)
|
|
{
|
|
return m_pMachine->LuaCallFunction( ON_ESTIM_DISPOSITION_START) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Estimator::CallOnDispositionEnd( void)
|
|
{
|
|
return m_pMachine->LuaCallFunction( ON_ESTIM_DISPOSITION_END) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Estimator::CallOnTableData( void)
|
|
{
|
|
if ( ! m_pMachine->LuaExistsFunction( ON_ESTIM_TABLE_DATA))
|
|
return true ;
|
|
return m_pMachine->LuaCallFunction( ON_ESTIM_TABLE_DATA) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Estimator::CallOnTableAxisData( void)
|
|
{
|
|
if ( ! m_pMachine->LuaExistsFunction( ON_ESTIM_TABLE_AXIS_DATA))
|
|
return true ;
|
|
return m_pMachine->LuaCallFunction( ON_ESTIM_TABLE_AXIS_DATA) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Estimator::CallOnFixtureData( void)
|
|
{
|
|
if ( ! m_pMachine->LuaExistsFunction( ON_ESTIM_FIXTURE_DATA))
|
|
return true ;
|
|
return m_pMachine->LuaCallFunction( ON_ESTIM_FIXTURE_DATA) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Estimator::CallOnRawMoveData( void)
|
|
{
|
|
if ( ! m_pMachine->LuaExistsFunction( ON_ESTIM_RAWMOVE_DATA))
|
|
return true ;
|
|
return m_pMachine->LuaCallFunction( ON_ESTIM_RAWMOVE_DATA) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Estimator::CallOnToolSelect( void)
|
|
{
|
|
return m_pMachine->LuaCallFunction( ON_ESTIM_TOOL_SELECT) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Estimator::CallOnToolDeselect( void)
|
|
{
|
|
return m_pMachine->LuaCallFunction( ON_ESTIM_TOOL_DESELECT) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Estimator::CallOnMachiningStart( void)
|
|
{
|
|
return m_pMachine->LuaCallFunction( ON_ESTIM_MACHINING_START) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Estimator::CallOnMachiningEnd( void)
|
|
{
|
|
return m_pMachine->LuaCallFunction( ON_ESTIM_MACHINING_END) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Estimator::CallOnPathStart( void)
|
|
{
|
|
if ( ! m_pMachine->LuaExistsFunction( ON_ESTIM_PATH_START))
|
|
return true ;
|
|
return m_pMachine->LuaCallFunction( ON_ESTIM_PATH_START) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Estimator::CallOnPathEnd( void)
|
|
{
|
|
if ( ! m_pMachine->LuaExistsFunction( ON_ESTIM_PATH_END))
|
|
return true ;
|
|
return m_pMachine->LuaCallFunction( ON_ESTIM_PATH_END) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Estimator::CallOnPathStartAux( void)
|
|
{
|
|
if ( ! m_pMachine->LuaExistsFunction( ON_ESTIM_PATH_START_AUX))
|
|
return true ;
|
|
return m_pMachine->LuaCallFunction( ON_ESTIM_PATH_START_AUX) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Estimator::CallOnPathEndAux( void)
|
|
{
|
|
if ( ! m_pMachine->LuaExistsFunction( ON_ESTIM_PATH_END_AUX))
|
|
return true ;
|
|
return m_pMachine->LuaCallFunction( ON_ESTIM_PATH_END_AUX) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Estimator::CallOnRapid( void)
|
|
{
|
|
return m_pMachine->LuaCallFunction( ON_ESTIM_RAPID) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Estimator::CallOnLinear( void)
|
|
{
|
|
return m_pMachine->LuaCallFunction( ON_ESTIM_LINEAR) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Estimator::CallOnArc( void)
|
|
{
|
|
return m_pMachine->LuaCallFunction( ON_ESTIM_ARC) ;
|
|
}
|