Files
EgtInterface/API_General.cpp
T
Dario Sassi 517a36a009 EgtInterface 1.5l1 :
- aggiornamento a VS2013
- alle curve si assegna in automatico estrusione come Z di griglia
- aggiunta gestione direttorio per librerie Lua
- aggiunta gestione frame di griglia (CPlane) in GeomDB
- aggiunta gestione visualizzazione riferimento globale
- aggiunto comando Lua EgtOffsetCurve
- aggiunti comandi Lua EgtExecTsc, EgtOutLog, EgtEraseFile, EgtEmptyDirectory, EgtTextFileCompare, EgtBinaryFileCompare, EgtGetVersion
- aggiunti comandi Lua EgtSetGridFrame, EgtGetGridFrame, EgtGetGridVersZ.
2014-12-17 15:19:20 +00:00

174 lines
4.8 KiB
C++

//----------------------------------------------------------------------------
// EgalTech 2014-2014
//----------------------------------------------------------------------------
// File : API_General.cpp Data : 01.09.14 Versione : 1.5i1
// Contenuto : Funzioni generali per API.
//
//
//
// Modifiche : 01.09.14 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "API.h"
#include "LUA.h"
#include "/EgtDev/Include/EInAPI.h"
#include "/EgtDev/Include/EInDllMain.h"
#include "/EgtDev/Include/EGkDllMain.h"
#include "/EgtDev/Include/ENkDllMain.h"
#include "/EgtDev/Include/EGnDllMain.h"
#include "/EgtDev/Include/EExDllMain.h"
#include "/EgtDev/Include/EGrDllMain.h"
#include "/EgtDev/Include/EGnStringConverter.h"
#include "/EgtDev/Include/EgtLogger.h"
#include <fstream>
using namespace std ;
using namespace egtlogger ;
//----------------------------------------------------------------------------
static Logger* s_pLogGen = nullptr ;
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtInit( int nDebug, const wchar_t* sLogFile)
{
// cancello eventuali vecchi contesti
ClearAllGseContexts() ;
// cancello eventuale vecchio logger
if ( s_pLogGen != nullptr)
delete s_pLogGen ;
// creo il logger generale
s_pLogGen = new Logger( ( nDebug > 0 ? LL_DEBUG : LL_INFO), "EgtInterface") ;
if ( s_pLogGen == nullptr)
return FALSE ;
// assegno il file
s_pLogGen->AddOutputStream( new ofstream( sLogFile), true) ;
// lo passo alle DLL
SetEGnLogger( s_pLogGen) ;
SetENkLogger( s_pLogGen) ;
SetEGkLogger( s_pLogGen) ;
SetEExLogger( s_pLogGen) ;
SetEGrLogger( s_pLogGen) ;
// dichiaro inizio programma
LOG_DATETIME( s_pLogGen, " Init")
// versione dell'interfaccia
LOG_INFO( s_pLogGen, GetEInVersion())
// versione delle librerie
LOG_INFO( s_pLogGen, GetEGnVersion())
LOG_INFO( s_pLogGen, GetENkVersion())
LOG_INFO( s_pLogGen, GetEGkVersion())
LOG_INFO( s_pLogGen, GetEExVersion())
LOG_INFO( s_pLogGen, GetEGrVersion())
// inizializzo l'interprete LUA
LuaInit() ;
return TRUE ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtExit( void)
{
// cancello tutti i contesti
ClearAllGseContexts() ;
// termino l'interprete LUA
LuaExit() ;
// fine programma
LOG_DATETIME( s_pLogGen, " Exit")
// cancello il logger
if ( s_pLogGen != nullptr) {
delete s_pLogGen ;
s_pLogGen = nullptr ;
}
return TRUE ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtSetKey( const wchar_t* sKey)
{
SetEGkKey( LPSTR( WtoA( sKey))) ;
return TRUE ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtSetFont( const wchar_t* wsNfeFontDir, const wchar_t* wsDefaultFont)
{
// inizializzazioni gestore font Nfe
InitFontManager( LPSTR( WtoA( wsNfeFontDir)), LPSTR( WtoA( wsDefaultFont))) ;
return TRUE ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtSetLuaLibs( const wchar_t* wsLuaLibsDir)
{
if ( LuaSetLuaLibsDir( LPSTR( WtoA( wsLuaLibsDir))))
return TRUE ;
else
return FALSE ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtGetVersionInfo( wchar_t*& wsVer)
{
// recupero le informazioni sulle DLL
string sVer ;
if ( ! EgtGetVersionInfo( sVer, "\r\n"))
return FALSE ;
wsVer = _wcsdup( stringtoW( sVer)) ;
return (( wsVer == nullptr) ? FALSE : TRUE) ;
}
//-----------------------------------------------------------------------------
bool
__stdcall EgtGetVersionInfo( string& sVer, const char* szNewLine)
{
// verifico il parametro
if ( &sVer == nullptr)
return false ;
// recupero le informazioni sulle DLL
sVer += GetEInVersion() ;
sVer += szNewLine ;
sVer += GetEGrVersion() ;
sVer += szNewLine ;
sVer += GetEExVersion() ;
sVer += szNewLine ;
sVer += GetEGkVersion() ;
sVer += szNewLine ;
sVer += GetENkVersion() ;
sVer += szNewLine ;
sVer += GetEGnVersion() ;
return true ;
}
//-----------------------------------------------------------------------------
BOOL
__stdcall EgtFreeMemory( void* pMem)
{
if ( pMem == nullptr)
return FALSE ;
free( pMem) ;
return TRUE ;
}
//-----------------------------------------------------------------------------
ILogger*
GetLogger( void)
{
return s_pLogGen ;
}