Files
EgtMachKernel/MachMgrSetup.cpp
T
Dario Sassi 823d97938e EgtMachKernel 1.8b2 :
- aggiunta funzione di interfaccia GetDefaultSetupName.
2017-02-06 10:16:54 +00:00

78 lines
2.4 KiB
C++

//----------------------------------------------------------------------------
// EgalTech 2017-2017
//----------------------------------------------------------------------------
// File : MachMgrSetup.cpp Data : 09.01.17 Versione : 1.6x5
// Contenuto : Implementazione gestione attrezzaggio della classe MachMgr.
//
//
//
// Modifiche : 09.01.17 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "DllMain.h"
#include "MachMgr.h"
#include "/EgtDev/Include/EgtIniFile.h"
using namespace std ;
//----------------------------------------------------------------------------
int
MachMgr::GetCurrSetup( void) const
{
return GetCurrSetupGroupId() ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetDefaultSetupName( string& sName) const
{
// verifico esista macchina corrente
Machine* pMch = GetCurrMachine() ;
if ( pMch == nullptr)
return false ;
// recupero da file Ini della macchina
//string sMachIni = m_sMachinesDir + "\\" + GetCurrMGeoName() + "\\" + GetCurrMGeoName() + ".ini" ;
string sMachIni = pMch->GetMachineDir() + "\\" + pMch->GetMachineName() + ".ini" ;
string sDefault = GetPrivateProfileStringUtf8( SETUP_SEC.c_str(), SETUP_DEF_KEY.c_str(), "", sMachIni.c_str()) ;
// se non trovato, errore
if ( IsEmptyOrSpaces( sDefault))
return false ;
// assegno il nome
sName = sDefault ;
return true ;
}
//----------------------------------------------------------------------------
bool
MachMgr::ImportSetup( const string& sName)
{
// definisco path completa del file di attrezzaggio
string sFileName = GetCurrSetupDir() + "\\" ;
// se ricevuto nome
if ( ! IsEmptyOrSpaces( sName)) {
sFileName += sName + "." + SETUP_EXT ;
}
// altrimenti cerco default
else {
string sDefault ;
if ( ! GetDefaultSetupName( sDefault))
return false ;
sFileName += sDefault + "." + SETUP_EXT ;
}
// gestione attrezzaggio
SetupMgr stuMgr ;
stuMgr.Init( this) ;
// importo l'attrezzaggio
if ( ! stuMgr.Import( sFileName))
return false ;
// lo inserisco nel progetto
return stuMgr.Save() ;
}