49d2577328
- sistemato aggiornamento utensili attrezzati in macchina al salvatggio DB utensili.
304 lines
9.5 KiB
C++
304 lines
9.5 KiB
C++
//----------------------------------------------------------------------------
|
|
// EgalTech 2015-2015
|
|
//----------------------------------------------------------------------------
|
|
// File : MachMgrDBTools.cpp Data : 17.09.15 Versione : 1.6i7
|
|
// Contenuto : Implementazione gestione DB utensili della classe MachMgr.
|
|
//
|
|
//
|
|
//
|
|
// Modifiche : 17.09.15 DS Creazione modulo.
|
|
//
|
|
//
|
|
//----------------------------------------------------------------------------
|
|
|
|
//--------------------------- Include ----------------------------------------
|
|
#include "stdafx.h"
|
|
#include "DllMain.h"
|
|
#include "MachMgr.h"
|
|
|
|
using namespace std ;
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
MachMgr::TdbGetToolNewName( string& sName) const
|
|
{
|
|
// recupero il gestore di utensili della macchina corrente
|
|
ToolsMgr* pTsMgr = GetCurrToolsMgr() ;
|
|
if ( pTsMgr == nullptr)
|
|
return false ;
|
|
// verifico nome ed eventualmente lo modifico per renderlo nuovo
|
|
return pTsMgr->GetToolNewName( sName) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
MachMgr::TdbAddTool( const string& sName, int nType)
|
|
{
|
|
// recupero il gestore di utensili della macchina corrente
|
|
ToolsMgr* pTsMgr = GetCurrToolsMgr() ;
|
|
if ( pTsMgr == nullptr)
|
|
return false ;
|
|
// aggiungo l'utensile al DB utensili
|
|
return pTsMgr->AddTool( sName, nType) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
MachMgr::TdbCopyTool( const string& sSource, const string& sName)
|
|
{
|
|
// recupero il gestore di utensili della macchina corrente
|
|
ToolsMgr* pTsMgr = GetCurrToolsMgr() ;
|
|
if ( pTsMgr == nullptr)
|
|
return false ;
|
|
// copio l'utensile nel DB utensili
|
|
return pTsMgr->CopyTool( sSource, sName) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
MachMgr::TdbRemoveTool( const string& sName)
|
|
{
|
|
// recupero il gestore di utensili della macchina corrente
|
|
ToolsMgr* pTsMgr = GetCurrToolsMgr() ;
|
|
if ( pTsMgr == nullptr)
|
|
return false ;
|
|
// rimuovo l'utensile dal DB utensili
|
|
return pTsMgr->RemoveTool( sName) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
MachMgr::TdbGetFirstTool( int nFamily, string& sName, int& nType) const
|
|
{
|
|
// recupero il gestore di utensili della macchina corrente
|
|
ToolsMgr* pTsMgr = GetCurrToolsMgr() ;
|
|
if ( pTsMgr == nullptr)
|
|
return false ;
|
|
// cerco il primo utensile della famiglia nel DB utensili
|
|
return pTsMgr->GetFirstTool( nFamily, sName, nType) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
MachMgr::TdbGetNextTool( int nFamily, string& sName, int& nType) const
|
|
{
|
|
// recupero il gestore di utensili della macchina corrente
|
|
ToolsMgr* pTsMgr = GetCurrToolsMgr() ;
|
|
if ( pTsMgr == nullptr)
|
|
return false ;
|
|
// cerco il successivo utensile della famiglia nel DB utensili
|
|
return pTsMgr->GetNextTool( nFamily, sName, nType) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
MachMgr::TdbGetToolFromUUID( const string& sTuuid, string& sName) const
|
|
{
|
|
// pulisco il parametro di ritorno
|
|
sName.clear() ;
|
|
// recupero il gestore di utensili della macchina corrente
|
|
ToolsMgr* pTsMgr = GetCurrToolsMgr() ;
|
|
if ( pTsMgr == nullptr)
|
|
return false ;
|
|
// cerco l'utensile con l'UUID, se trovato ne restituisco il nome
|
|
EgtUUID Tuuid ;
|
|
if ( ! FromString( sTuuid, Tuuid))
|
|
return false ;
|
|
const ToolData* pTdata = pTsMgr->GetTool( Tuuid) ;
|
|
if ( pTdata == nullptr)
|
|
return false ;
|
|
sName = pTdata->m_sName ;
|
|
return true ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
MachMgr::TdbSetCurrTool( const string& sName)
|
|
{
|
|
// recupero il gestore di utensili della macchina corrente
|
|
ToolsMgr* pTsMgr = GetCurrToolsMgr() ;
|
|
if ( pTsMgr == nullptr)
|
|
return false ;
|
|
// imposto l'utensile corrente
|
|
return pTsMgr->SetCurrTool( sName) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
MachMgr::TdbSaveCurrTool( void)
|
|
{
|
|
// recupero il gestore di utensili della macchina corrente
|
|
ToolsMgr* pTsMgr = GetCurrToolsMgr() ;
|
|
if ( pTsMgr == nullptr)
|
|
return false ;
|
|
// salvo l'utensile corrente
|
|
return pTsMgr->SaveCurrTool() ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
MachMgr::TdbIsCurrToolModified( void) const
|
|
{
|
|
// recupero il gestore di utensili della macchina corrente
|
|
ToolsMgr* pTsMgr = GetCurrToolsMgr() ;
|
|
if ( pTsMgr == nullptr)
|
|
return false ;
|
|
// verifico se l'utensile corrente è stato modificato
|
|
return pTsMgr->IsCurrToolModified() ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
MachMgr::TdbSetCurrToolParam( int nType, bool bVal)
|
|
{
|
|
// recupero il gestore di utensili della macchina corrente
|
|
ToolsMgr* pTsMgr = GetCurrToolsMgr() ;
|
|
if ( pTsMgr == nullptr)
|
|
return false ;
|
|
// assegno il parametro
|
|
return pTsMgr->SetCurrToolParam( nType, bVal) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
MachMgr::TdbSetCurrToolParam( int nType, int nVal)
|
|
{
|
|
// recupero il gestore di utensili della macchina corrente
|
|
ToolsMgr* pTsMgr = GetCurrToolsMgr() ;
|
|
if ( pTsMgr == nullptr)
|
|
return false ;
|
|
// assegno il parametro
|
|
return pTsMgr->SetCurrToolParam( nType, nVal) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
MachMgr::TdbSetCurrToolParam( int nType, double dVal)
|
|
{
|
|
// recupero il gestore di utensili della macchina corrente
|
|
ToolsMgr* pTsMgr = GetCurrToolsMgr() ;
|
|
if ( pTsMgr == nullptr)
|
|
return false ;
|
|
// assegno il parametro
|
|
return pTsMgr->SetCurrToolParam( nType, dVal) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
MachMgr::TdbSetCurrToolParam( int nType, const string& sVal)
|
|
{
|
|
// recupero il gestore di utensili della macchina corrente
|
|
ToolsMgr* pTsMgr = GetCurrToolsMgr() ;
|
|
if ( pTsMgr == nullptr)
|
|
return false ;
|
|
// assegno il parametro
|
|
return pTsMgr->SetCurrToolParam( nType, sVal) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
MachMgr::TdbGetCurrToolParam( int nType, bool& bVal) const
|
|
{
|
|
// recupero il gestore di utensili della macchina corrente
|
|
ToolsMgr* pTsMgr = GetCurrToolsMgr() ;
|
|
if ( pTsMgr == nullptr)
|
|
return false ;
|
|
// recupero il parametro
|
|
return pTsMgr->GetCurrToolParam( nType, bVal) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
MachMgr::TdbGetCurrToolParam( int nType, int& nVal) const
|
|
{
|
|
// recupero il gestore di utensili della macchina corrente
|
|
ToolsMgr* pTsMgr = GetCurrToolsMgr() ;
|
|
if ( pTsMgr == nullptr)
|
|
return false ;
|
|
// recupero il parametro
|
|
return pTsMgr->GetCurrToolParam( nType, nVal) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
MachMgr::TdbGetCurrToolParam( int nType, double& dVal) const
|
|
{
|
|
// recupero il gestore di utensili della macchina corrente
|
|
ToolsMgr* pTsMgr = GetCurrToolsMgr() ;
|
|
if ( pTsMgr == nullptr)
|
|
return false ;
|
|
// recupero il parametro
|
|
return pTsMgr->GetCurrToolParam( nType, dVal) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
MachMgr::TdbGetCurrToolParam( int nType, string& sVal) const
|
|
{
|
|
// recupero il gestore di utensili della macchina corrente
|
|
ToolsMgr* pTsMgr = GetCurrToolsMgr() ;
|
|
if ( pTsMgr == nullptr)
|
|
return false ;
|
|
// recupero il parametro
|
|
return pTsMgr->GetCurrToolParam( nType, sVal) ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
MachMgr::TdbReload( void)
|
|
{
|
|
// recupero il gestore di utensili della macchina corrente
|
|
ToolsMgr* pTsMgr = GetCurrToolsMgr() ;
|
|
if ( pTsMgr == nullptr)
|
|
return nullptr ;
|
|
// ricarico il db utensili
|
|
return pTsMgr->Reload() ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
MachMgr::TdbSave( void) const
|
|
{
|
|
// recupero il gestore di utensili della macchina corrente
|
|
ToolsMgr* pTsMgr = GetCurrToolsMgr() ;
|
|
if ( pTsMgr == nullptr)
|
|
return nullptr ;
|
|
// se non ci sono state modifiche, esco subito
|
|
if ( ! pTsMgr->GetModified())
|
|
return true ;
|
|
// salvo il db utensili
|
|
if ( ! pTsMgr->Save())
|
|
return false ;
|
|
// se macchina caricata, ne scarico e ricarico tutti gli utensili
|
|
if ( IsCurrMachineLoaded()) {
|
|
Machine* pMach = GetCurrMachine() ;
|
|
if ( pMach != nullptr) {
|
|
pMach->UnloadAllTools() ;
|
|
pMach->LoadAllTools() ;
|
|
}
|
|
}
|
|
return true ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
MachMgr::TdbGetToolDir( string& sToolDir) const
|
|
{
|
|
string sMachineName ;
|
|
if ( ! GetCurrMachineName( sMachineName))
|
|
return false ;
|
|
sToolDir = m_sMachinesDir + "\\" + sMachineName + "\\" + TOOLS_DIR ;
|
|
return true ;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
bool
|
|
MachMgr::TdbGetToolHolderDir( string& sToolDir) const
|
|
{
|
|
string sMachineName ;
|
|
if ( ! GetCurrMachineName( sMachineName))
|
|
return false ;
|
|
sToolDir = m_sMachinesDir + "\\" + sMachineName + "\\" + TOOLHOLDERS_DIR ;
|
|
return true ;
|
|
}
|