Files
EgtMachKernel/MachMgrSetup.cpp
DarioS 7125453424 EgtMachKernel 2.3g4 :
- versione x64 compilata con Clang-cl/LLVM
- modifiche varie per eliminare warning più gravi di questo compilatore.
2021-07-20 14:47:48 +02:00

164 lines
5.2 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 ;
}
// importo l'attrezzaggio
if ( ! m_stuMgr.Import( sFileName))
return false ;
// lo inserisco nel progetto
return m_stuMgr.Save() ;
}
//----------------------------------------------------------------------------
bool
MachMgr::VerifyCurrSetup( STRVECTOR& vsErrors)
{
// pulizia vettore degli utensili mancanti
vsErrors.clear() ;
// 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
string sTcPos, sHead ; int nExit ;
if ( ! m_stuMgr.GetToolData( sTool, sTcPos, sHead, nExit)) {
// se non presente nella lista dei non attrezzati, lo aggiungo
if ( find( vsErrors.begin(), vsErrors.end(), sTool) == vsErrors.end())
vsErrors.push_back( sTool) ;
}
// altrimenti, verifico se uscita coincide con quella indicata nel DB utensili
else {
int nTdbExit = 0 ;
if ( ! TdbSetCurrTool( sTool) ||
! TdbGetCurrToolParam( TPA_EXIT, nTdbExit) ||
nExit != nTdbExit) {
string sErr = sTool + " (exit mismatch " + ToString( nExit) + " - " + ToString( nTdbExit) + ")" ;
vsErrors.push_back( sErr) ;
}
}
}
// passo alla operazione successiva
nOpId = GetNextActiveOperation( nOpId) ;
}
return vsErrors.empty() ;
}
//----------------------------------------------------------------------------
bool
MachMgr::FindToolInCurrSetup( const string& sTool)
{
return m_stuMgr.FindTool( sTool) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetToolsInCurrSetupPos( const string& sTcPos, STRVECTOR& vsTools)
{
return m_stuMgr.GetToolsInSetupPos( sTcPos, vsTools) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::UpdateCurrSetup( void)
{
// aggiorno attrezzaggio
if ( ! m_stuMgr.Load())
return false ;
// carico utensili relativi
Machine* pMch = GetCurrMachine() ;
if ( pMch == nullptr)
return false ;
return pMch->LoadAllTools() ;
}
//----------------------------------------------------------------------------
bool
MachMgr::EraseCurrSetup( void)
{
// pulisco attrezzaggio
if ( ! m_stuMgr.Clear())
return false ;
// salvo i dati
return m_stuMgr.Save() ;
}