Files
EgtMachKernel/MachMgrSetup.cpp
T
Dario Sassi 6fce5b366d EgtMachKernel 1.8c3 :
- prima versione funzionante di lavorazione generica con script lua
- corretta funzione per Lua EmtAddArcMove
- aggiunta VerifyAngleOutstroke
- corretta assegnazione valore precedente ad asse indeterminato
- corretta assegnazione angoli tenendo conto dei precedenti durante lavorazione.
2017-03-08 19:47:08 +00:00

123 lines
3.9 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 = 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() ;
}
//----------------------------------------------------------------------------
bool
MachMgr::VerifyCurrSetup( STRVECTOR& vsErrors)
{
// pulizia vettore degli utensili mancanti
vsErrors.clear() ;
// recupero attrezzaggio corrente
SetupMgr stuMgr ;
if ( ! stuMgr.Init( this) || ! stuMgr.Load())
return false ;
// ciclo sulle lavorazioni della macchinata corrente per ricavare gli utensili utilizzati
int nOpId = GetFirstActiveOperation() ;
while ( nOpId != GDB_ID_NULL) {
// processo l'operazione
int nType = GetOperationType( nOpId) ;
if ( IsValidMachiningType( nType)) {
// Imposto come lavorazione corrente
if ( ! SetCurrMachining( nOpId))
continue ;
// Recupero l'utensile della lavorazione corrente
string sTuuid, sTool ;
if ( ! GetMachiningParam( MPA_TUUID, sTuuid) ||
! TdbGetToolFromUUID( sTuuid, sTool)) {
string sMchName ;
m_pGeomDB->GetName( nOpId, sMchName) ;
string sToolName ;
GetMachiningParam( MPA_TOOL, sToolName) ;
string sErr = sMchName + "/" + sToolName ;
vsErrors.push_back( sErr) ;
}
// Se utensile non attrezzato
if ( ! stuMgr.FindTool( sTool)) {
// se non presente nella lista dei non attrezzati, lo aggiungo
if ( find( vsErrors.begin(), vsErrors.end(), sTool) == vsErrors.end())
vsErrors.push_back( sTool) ;
}
}
// passo alla operazione successiva
nOpId = GetNextActiveOperation( nOpId) ;
}
return vsErrors.empty() ;
}