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.
285 lines
8.4 KiB
C++
285 lines
8.4 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2015-2018
|
|
//----------------------------------------------------------------------------
|
|
// File : Generator.cpp Data : 28.05.18 Versione : 1.9e6
|
|
// Contenuto : Implementazione della classe Generator.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 28.10.15 DS Creazione modulo.
|
|
// 26.02.16 DS Aggiunta gestione archi.
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "DllMain.h"
|
|
#include "Generator.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" ;
|
|
|
|
//----------------------------------------------------------------------------
|
|
Generator::Generator( void)
|
|
{
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
Generator::~Generator( void)
|
|
{
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Generator::Init( MachMgr* pMchMgr)
|
|
{
|
|
return Processor::Init( pMchMgr) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Generator::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 bNcOff = false ;
|
|
if ( ( nOpt1 & KEYOPT_EMK_NC_OFF) != 0)
|
|
bNcOff = true ;
|
|
bool bAdvMach = false ;
|
|
if ( ( nOpt1 & KEYOPT_EMK_ADV) != 0)
|
|
bAdvMach = true ;
|
|
|
|
// Esecuzione
|
|
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 ;
|
|
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 = ( bNcOff ? "Warning on Key (MKC/NCO)" : "Warning on Key (MKC/KYO)") ;
|
|
LOG_ERROR( GetEMkLogger(), sErr.c_str()) ;
|
|
return false ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Generator::CallOnStart( void)
|
|
{
|
|
return m_pMachine->LuaCallFunction( ON_START) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Generator::CallOnEnd( void)
|
|
{
|
|
return m_pMachine->LuaCallFunction( ON_END) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Generator::CallOnProgramStart( void)
|
|
{
|
|
return m_pMachine->LuaCallFunction( ON_PROGRAM_START) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Generator::CallOnProgramEnd( void)
|
|
{
|
|
return m_pMachine->LuaCallFunction( ON_PROGRAM_END) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Generator::CallOnToolData( void)
|
|
{
|
|
if ( ! m_pMachine->LuaExistsFunction( ON_TOOL_DATA))
|
|
return true ;
|
|
return m_pMachine->LuaCallFunction( ON_TOOL_DATA) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Generator::CallOnDispositionStart( void)
|
|
{
|
|
return m_pMachine->LuaCallFunction( ON_DISPOSITION_START) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Generator::CallOnDispositionEnd( void)
|
|
{
|
|
return m_pMachine->LuaCallFunction( ON_DISPOSITION_END) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Generator::CallOnTableData( void)
|
|
{
|
|
return m_pMachine->LuaCallFunction( ON_TABLE_DATA) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Generator::CallOnTableAxisData( void)
|
|
{
|
|
return m_pMachine->LuaCallFunction( ON_TABLE_AXIS_DATA) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Generator::CallOnFixtureData( void)
|
|
{
|
|
return m_pMachine->LuaCallFunction( ON_FIXTURE_DATA) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Generator::CallOnRawMoveData( void)
|
|
{
|
|
return m_pMachine->LuaCallFunction( ON_RAWMOVE_DATA) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Generator::CallOnToolSelect( void)
|
|
{
|
|
return m_pMachine->LuaCallFunction( ON_TOOL_SELECT) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Generator::CallOnToolDeselect( void)
|
|
{
|
|
return m_pMachine->LuaCallFunction( ON_TOOL_DESELECT) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Generator::CallOnMachiningStart( void)
|
|
{
|
|
return m_pMachine->LuaCallFunction( ON_MACHINING_START) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Generator::CallOnMachiningEnd( void)
|
|
{
|
|
return m_pMachine->LuaCallFunction( ON_MACHINING_END) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Generator::CallOnPathStart( void)
|
|
{
|
|
return m_pMachine->LuaCallFunction( ON_PATH_START) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Generator::CallOnPathEnd( void)
|
|
{
|
|
return m_pMachine->LuaCallFunction( ON_PATH_END) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Generator::CallOnPathStartAux( void)
|
|
{
|
|
if ( ! m_pMachine->LuaExistsFunction( ON_PATH_START_AUX))
|
|
return true ;
|
|
return m_pMachine->LuaCallFunction( ON_PATH_START_AUX) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Generator::CallOnPathEndAux( void)
|
|
{
|
|
if ( ! m_pMachine->LuaExistsFunction( ON_PATH_END_AUX))
|
|
return true ;
|
|
return m_pMachine->LuaCallFunction( ON_PATH_END_AUX) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Generator::CallOnRapid( void)
|
|
{
|
|
return m_pMachine->LuaCallFunction( ON_RAPID) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Generator::CallOnLinear( void)
|
|
{
|
|
return m_pMachine->LuaCallFunction( ON_LINEAR) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
Generator::CallOnArc( void)
|
|
{
|
|
return m_pMachine->LuaCallFunction( ON_ARC) ;
|
|
}
|