156f0f8ef8
- modifiche per prima versione chiave di rete.
241 lines
6.7 KiB
C++
241 lines
6.7 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/EMkDllMain.h"
|
|
#include "/EgtDev/Include/EGnFileUtils.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)
|
|
{
|
|
// verifico sia abilitato dalla licenza
|
|
bool bEnabled = false ;
|
|
if ( GetEMkNetHwKey()) {
|
|
bEnabled = true ;
|
|
}
|
|
else {
|
|
unsigned int nOpt1, nOpt2 ;
|
|
int nOptExpDays ;
|
|
int nRet = GetKeyOptions( GetEMkKey(), KEY_BASELIB_PROD, KEY_BASELIB_VER, KEY_BASELIB_LEV,
|
|
nOpt1, nOpt2, nOptExpDays) ;
|
|
bEnabled = ( nRet == KEY_OK && ( nOpt1 & KEYOPT_EMK_NC_OFF) == 0) ;
|
|
}
|
|
if ( bEnabled) {
|
|
|
|
// 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 ;
|
|
}
|
|
|
|
// Generazione non abilitata
|
|
m_pMchMgr->SetLastError( 1000, "NC_OFF") ;
|
|
std::string sErr = "Warning on Key (MKC/NCO)" ;
|
|
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::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) ;
|
|
}
|