EgtMachKernel 1.9k2 :
- aggiunta gestione massimo affondamento di utensile TdbGetCurrToolMaxDepth - for each (.. in ..) sostituito da for ( .. : ..) vero costrutto C++.
This commit is contained in:
Binary file not shown.
@@ -1,7 +1,7 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2015-2015
|
||||
// EgalTech 2015-2018
|
||||
//----------------------------------------------------------------------------
|
||||
// File : MachMgr.h Data : 23.03.15 Versione : 1.6c6
|
||||
// File : MachMgr.h Data : 27.11.18 Versione : 1.9k2
|
||||
// Contenuto : Dichiarazione della classe MachMgr.
|
||||
//
|
||||
//
|
||||
@@ -166,6 +166,7 @@ class MachMgr : public IMachMgr
|
||||
bool TdbGetCurrToolParam( int nType, int& nVal) const override ;
|
||||
bool TdbGetCurrToolParam( int nType, double& dVal) const override ;
|
||||
bool TdbGetCurrToolParam( int nType, std::string& sVal) const override ;
|
||||
bool TdbGetCurrToolMaxDepth( double& dMaxDepth) const override ;
|
||||
bool TdbReload( void) override ;
|
||||
bool TdbSave( void) const override ;
|
||||
bool TdbGetToolDir( std::string& sToolDir) const override ;
|
||||
|
||||
@@ -243,6 +243,18 @@ MachMgr::TdbGetCurrToolParam( int nType, string& sVal) const
|
||||
return pTsMgr->GetCurrToolParam( nType, sVal) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
MachMgr::TdbGetCurrToolMaxDepth( double& dMaxDepth) const
|
||||
{
|
||||
// recupero il gestore di utensili della macchina corrente
|
||||
ToolsMgr* pTsMgr = GetCurrToolsMgr() ;
|
||||
if ( pTsMgr == nullptr)
|
||||
return false ;
|
||||
// recupero il massimo affondamento
|
||||
return pTsMgr->GetCurrToolMaxDepth( dMaxDepth) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
MachMgr::TdbReload( void)
|
||||
|
||||
+2
-2
@@ -149,8 +149,8 @@ MachMgr::GetCurrToolsMgr( void) const
|
||||
// se DB utensili non esiste, provo a crearlo e caricarlo
|
||||
if ( m_vMachines[m_nCurrMch].pTsMgr == nullptr) {
|
||||
PtrOwner<ToolsMgr> pTsMgr( new( nothrow) ToolsMgr) ;
|
||||
string sToolsFile = m_sMachinesDir + "\\" + m_vMachines[m_nCurrMch].sName + "\\" + TOOLS_DIR + "\\" + TOOLS_FILE ;
|
||||
if ( IsNull( pTsMgr) || ! pTsMgr->Load( sToolsFile))
|
||||
string sToolsDir = m_sMachinesDir + "\\" + m_vMachines[m_nCurrMch].sName + "\\" + TOOLS_DIR ;
|
||||
if ( IsNull( pTsMgr) || ! pTsMgr->Load( sToolsDir, TOOLS_FILE))
|
||||
return nullptr ;
|
||||
// salvo nel vettore
|
||||
const_cast<MachineData&>( m_vMachines[m_nCurrMch]).pTsMgr = Release( pTsMgr) ;
|
||||
|
||||
+1
-1
@@ -350,7 +350,7 @@ Machine::GetCurrHeadCollGroups( INTVECTOR& vIds) const
|
||||
vIds.push_back( m_nCalcHeadId) ;
|
||||
// recupero stringhe con gruppi ausiliari di collisione
|
||||
const STRVECTOR& vsOthColl = pHead->GetOtherCollGroups() ;
|
||||
for each ( const auto& sOthColl in vsOthColl) {
|
||||
for ( const auto& sOthColl : vsOthColl) {
|
||||
string sGrp, sSub ;
|
||||
Split( sOthColl, "/", true, sGrp, sSub) ;
|
||||
int nId = GetGroup( sGrp) ;
|
||||
|
||||
+3
-3
@@ -30,7 +30,7 @@ Machine::GetAllHeadsNames( STRVECTOR& vNames) const
|
||||
// reset lista nomi
|
||||
vNames.clear() ;
|
||||
// ricerca delle teste
|
||||
for each ( const auto& snGro in m_mapGroups) {
|
||||
for ( const auto& snGro : m_mapGroups) {
|
||||
if ( IsHeadGroup( snGro.second))
|
||||
vNames.push_back( snGro.first) ;
|
||||
}
|
||||
@@ -266,7 +266,7 @@ Machine::LoadAllTools( void)
|
||||
if ( ! m_pMchMgr->GetCurrSetupMgr().Exists())
|
||||
return true ;
|
||||
// ciclo su tutte le teste
|
||||
for each ( const auto& snGro in m_mapGroups) {
|
||||
for ( const auto& snGro : m_mapGroups) {
|
||||
if ( IsHeadGroup( snGro.second)) {
|
||||
// recupero l'insieme di appartenenza della testa
|
||||
const STRVECTOR& vsHSet = GetHSet( snGro.first) ;
|
||||
@@ -320,7 +320,7 @@ Machine::UnloadAllTools( void)
|
||||
return false ;
|
||||
// ciclo su tutte le teste
|
||||
bool bOk = true ;
|
||||
for each ( const auto& snGro in m_mapGroups) {
|
||||
for ( const auto& snGro : m_mapGroups) {
|
||||
if ( IsHeadGroup( snGro.second)) {
|
||||
if ( ! UnloadTools( snGro.first))
|
||||
bOk = false ;
|
||||
|
||||
+2
-2
@@ -30,7 +30,7 @@ Machine::GetAllTablesNames( STRVECTOR& vNames) const
|
||||
// reset lista nomi
|
||||
vNames.clear() ;
|
||||
// ricerca delle tavole
|
||||
for each ( const auto& snGro in m_mapGroups) {
|
||||
for ( const auto& snGro : m_mapGroups) {
|
||||
if ( IsTableGroup( snGro.second))
|
||||
vNames.push_back( snGro.first) ;
|
||||
}
|
||||
@@ -44,7 +44,7 @@ int
|
||||
Machine::GetFirstTable( void) const
|
||||
{
|
||||
// ricerca della prima tavola
|
||||
for each ( const auto& snGro in m_mapGroups) {
|
||||
for ( const auto& snGro : m_mapGroups) {
|
||||
if ( IsTableGroup( snGro.second))
|
||||
return snGro.second ;
|
||||
}
|
||||
|
||||
+3
-3
@@ -875,7 +875,7 @@ Operation::ExtractInfo( const string& sNotes, const string& sKey)
|
||||
string sInfo ;
|
||||
STRVECTOR vsCmd ;
|
||||
Tokenize( sNotes, ";", vsCmd) ;
|
||||
for each (const auto& sCmd in vsCmd) {
|
||||
for (const auto& sCmd : vsCmd) {
|
||||
// se per assi rotanti
|
||||
if ( sCmd.find( sKey) != string::npos) {
|
||||
sInfo = sCmd ;
|
||||
@@ -951,7 +951,7 @@ Operation::CalculateAxesValues( const string& sHint, bool bSolChExact)
|
||||
if ( ! sHint.empty()) {
|
||||
STRVECTOR vsTok ;
|
||||
Tokenize( sHint, ",", vsTok) ;
|
||||
for each (const auto& sTok in vsTok) {
|
||||
for (const auto& sTok : vsTok) {
|
||||
string szKey, szVal ;
|
||||
Split( sTok, "=", true, szKey, szVal) ;
|
||||
for ( int i = 0 ; i < nRotAxes ; ++ i) {
|
||||
@@ -2012,7 +2012,7 @@ Operation::TestCollisionAvoid( const DBLVECTOR& vAxStart, const DBLVECTOR& vAxEn
|
||||
BBox3d b3Head ;
|
||||
INTVECTOR vCollId ;
|
||||
pMch->GetCurrHeadCollGroups( vCollId) ;
|
||||
for each ( int nCId in vCollId) {
|
||||
for ( int nCId : vCollId) {
|
||||
int nHId = m_pGeomDB->GetFirstInGroup( nCId) ;
|
||||
while ( nHId != GDB_ID_NULL) {
|
||||
BBox3d b3Tmp ;
|
||||
|
||||
+1
-1
@@ -162,7 +162,7 @@ Processor::VerifySetup( void)
|
||||
|
||||
// gestisco errore
|
||||
string sErr = "Error with setup :" ;
|
||||
for each( const auto& sTmp in vsErr)
|
||||
for ( const auto& sTmp : vsErr)
|
||||
sErr += " " + sTmp ;
|
||||
m_pMchMgr->SetLastError( 1001, sErr) ;
|
||||
return false ;
|
||||
|
||||
+1
-1
@@ -155,7 +155,7 @@ Simulator::VerifySetup( void)
|
||||
|
||||
// gestisco errore
|
||||
string sErr = "Error with setup :" ;
|
||||
for each( const auto& sTmp in vsErr)
|
||||
for ( const auto& sTmp : vsErr)
|
||||
sErr += " " + sTmp ;
|
||||
m_pMchMgr->SetLastError( 1001, sErr) ;
|
||||
return false ;
|
||||
|
||||
+86
-7
@@ -17,11 +17,14 @@
|
||||
#include "stdafx.h"
|
||||
#include "ToolsMgr.h"
|
||||
#include "DllMain.h"
|
||||
#include "MachConst.h"
|
||||
#include "/EgtDev/Include/EGkGeomDB.h"
|
||||
#include "/EgtDEv/Include/EmkToolConst.h"
|
||||
#include "/EgtDEv/Include/EGnStringKeyVal.h"
|
||||
#include "/EgtDEv/Include/EGnFileUtils.h"
|
||||
#include "/EgtDEv/Include/EGnScanner.h"
|
||||
#include "/EgtDEv/Include/EGnWriter.h"
|
||||
#include "/EgtDev/Include/EgtPointerOwner.h"
|
||||
#include <cassert>
|
||||
#include <bitset>
|
||||
|
||||
@@ -58,11 +61,12 @@ ToolsMgr::Clear( void)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ToolsMgr::Load( const string& sToolsFile)
|
||||
ToolsMgr::Load( const string& sToolsDir, const string& sToolsFile)
|
||||
{
|
||||
// salvo la path del file con i dati
|
||||
m_sToolsFile = sToolsFile ;
|
||||
string sOut = "ToolsMgr Init : " + m_sToolsFile ;
|
||||
m_sToolsDir = sToolsDir ;
|
||||
m_sToolsPath = m_sToolsDir + "\\" + sToolsFile ;
|
||||
string sOut = "ToolsMgr Init : " + m_sToolsPath ;
|
||||
LOG_INFO( GetEMkLogger(), sOut.c_str())
|
||||
|
||||
// carico
|
||||
@@ -78,7 +82,7 @@ ToolsMgr::Reload( void)
|
||||
|
||||
// inizializzo lo scanner
|
||||
Scanner TheScanner ;
|
||||
if ( ! TheScanner.Init( m_sToolsFile, ";")) {
|
||||
if ( ! TheScanner.Init( m_sToolsPath, ";")) {
|
||||
LOG_ERROR( GetEMkLogger(), "ReloadTools : Error on Init")
|
||||
return false ;
|
||||
}
|
||||
@@ -223,17 +227,17 @@ ToolsMgr::Save( bool bCompressed) const
|
||||
return true ;
|
||||
|
||||
// faccio copia di backup del file originale
|
||||
CopyFileEgt( m_sToolsFile, m_sToolsFile + ".bak") ;
|
||||
CopyFileEgt( m_sToolsPath, m_sToolsPath + ".bak") ;
|
||||
|
||||
// inizializzo il writer
|
||||
Writer TheWriter ;
|
||||
if ( ! TheWriter.Init( m_sToolsFile, bCompressed)) {
|
||||
if ( ! TheWriter.Init( m_sToolsPath, bCompressed)) {
|
||||
LOG_ERROR( GetEMkLogger(), "SaveTools : Error on Init")
|
||||
return false ;
|
||||
}
|
||||
|
||||
// scrivo linea di inizio file
|
||||
string sOut = "; --- " + m_sToolsFile + " " + CurrDateTime() + " ---" ;
|
||||
string sOut = "; --- " + m_sToolsPath + " " + CurrDateTime() + " ---" ;
|
||||
if ( ! TheWriter.OutText( sOut)) {
|
||||
LOG_ERROR( GetEMkLogger(), "SaveTools : Error on Start")
|
||||
return false ;
|
||||
@@ -527,12 +531,34 @@ ToolsMgr::SaveCurrTool( void)
|
||||
m_suData.emplace( m_tdCurrTool.m_sName, m_tdCurrTool.m_Uuid) ;
|
||||
}
|
||||
}
|
||||
// aggiorno dati portautensile
|
||||
UpdateCurrToolHolderData() ;
|
||||
// eseguo salvataggio
|
||||
m_bModified = true ;
|
||||
iIter->second = m_tdCurrTool ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ToolsMgr::UpdateCurrToolHolderData( void)
|
||||
{
|
||||
// Leggo i dati del portautensile dal disegno dell'utensile
|
||||
PtrOwner<IGeomDB> pGeomDB( CreateGeomDB()) ;
|
||||
pGeomDB->Init() ;
|
||||
string sDrawPath = m_sToolsDir + "\\" + m_tdCurrTool.m_sDraw ;
|
||||
pGeomDB->Load( sDrawPath) ;
|
||||
int nToolId = pGeomDB->GetFirstGroupInGroup( GDB_ID_ROOT) ;
|
||||
double dTHoldLen = 0 ;
|
||||
pGeomDB->GetInfo( nToolId, TTH_LEN, dTHoldLen) ;
|
||||
double dTHoldDiam = 0 ;
|
||||
pGeomDB->GetInfo( nToolId, TTH_DIAM, dTHoldDiam) ;
|
||||
// Aggiorno i dati nelle note di sistema
|
||||
SetValInNotes( TSI_THLEN, dTHoldLen, m_tdCurrTool.m_sSysNotes) ;
|
||||
SetValInNotes( TSI_THDIAM, dTHoldDiam, m_tdCurrTool.m_sSysNotes) ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ToolsMgr::IsCurrToolModified( void) const
|
||||
@@ -618,3 +644,56 @@ ToolsMgr::GetCurrToolParam( int nType, string& sVal) const
|
||||
{
|
||||
return ( m_bCurrTool ? m_tdCurrTool.GetParam( nType, sVal) : false) ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ToolsMgr::GetCurrToolMaxDepth( double& dMaxDepth) const
|
||||
{
|
||||
// verifico esistenza utensile corrente
|
||||
if ( ! m_bCurrTool)
|
||||
return false ;
|
||||
|
||||
// se punta a forare
|
||||
if ( ( m_tdCurrTool.m_nType & TF_DRILLBIT) != 0) {
|
||||
dMaxDepth = m_tdCurrTool.m_dMaxMat ;
|
||||
return true ;
|
||||
}
|
||||
// se lama
|
||||
else if ( ( m_tdCurrTool.m_nType & TF_SAWBLADE) != 0) {
|
||||
dMaxDepth = m_tdCurrTool.m_dMaxMat ;
|
||||
return true ;
|
||||
}
|
||||
// se fresa
|
||||
else if ( ( m_tdCurrTool.m_nType & TF_MILL) != 0) {
|
||||
// recupero le dimensioni del porta utensili
|
||||
double dTHoldLen = 0 ;
|
||||
double dTHoldDiam = 0 ;
|
||||
if ( ! GetValInNotes( m_tdCurrTool.m_sSysNotes, TSI_THLEN, dTHoldLen) ||
|
||||
! GetValInNotes( m_tdCurrTool.m_sSysNotes, TSI_THDIAM, dTHoldDiam)) {
|
||||
(const_cast<ToolsMgr*>(this))->SaveCurrTool() ;
|
||||
Save() ;
|
||||
GetValInNotes( m_tdCurrTool.m_sSysNotes, TSI_THLEN, dTHoldLen) ;
|
||||
GetValInNotes( m_tdCurrTool.m_sSysNotes, TSI_THDIAM, dTHoldDiam) ;
|
||||
}
|
||||
// calcolo il massimo affondamento
|
||||
dMaxDepth = m_tdCurrTool.m_dLen - ( m_tdCurrTool.m_dDiam > dTHoldDiam ? 0 : dTHoldLen) - MAX_DEPTH_SAFE ;
|
||||
return true ;
|
||||
}
|
||||
// se mortasatrice o sega a catena
|
||||
else if ( ( m_tdCurrTool.m_nType & TF_MORTISE) != 0) {
|
||||
dMaxDepth = m_tdCurrTool.m_dMaxMat ;
|
||||
return true ;
|
||||
}
|
||||
// se scalpello
|
||||
else if ( ( m_tdCurrTool.m_nType & TF_CHISEL) != 0) {
|
||||
dMaxDepth = m_tdCurrTool.m_dMaxMat ;
|
||||
return true ;
|
||||
}
|
||||
// utensile composito
|
||||
else if ( ( m_tdCurrTool.m_nType & TF_COMPO) != 0) {
|
||||
// non ancora gestito
|
||||
return false ;
|
||||
}
|
||||
|
||||
return false ;
|
||||
}
|
||||
|
||||
+5
-2
@@ -25,7 +25,7 @@ class ToolsMgr
|
||||
{
|
||||
public :
|
||||
ToolsMgr( void) ;
|
||||
bool Load( const std::string& sToolsFile) ;
|
||||
bool Load( const std::string& sToolsDir, const std::string& sToolsFile) ;
|
||||
bool Reload( void) ;
|
||||
bool GetModified( void)
|
||||
{ return m_bModified ; }
|
||||
@@ -49,6 +49,7 @@ class ToolsMgr
|
||||
bool GetCurrToolParam( int nType, int& nVal) const ;
|
||||
bool GetCurrToolParam( int nType, double& dVal) const ;
|
||||
bool GetCurrToolParam( int nType, std::string& sVal) const ;
|
||||
bool GetCurrToolMaxDepth( double& dMaxDepth) const ;
|
||||
|
||||
private :
|
||||
bool Clear( void) ;
|
||||
@@ -57,6 +58,7 @@ class ToolsMgr
|
||||
bool SaveHeader( Writer& TheWriter) const ;
|
||||
bool SaveOneTool( const EgtUUID& Uuid, int& nCounter, Writer& TheWriter) const ;
|
||||
bool VerifyTool( int nFamily, std::string& sName, int& nType) const ;
|
||||
bool UpdateCurrToolHolderData( void) ;
|
||||
|
||||
private :
|
||||
typedef std::unordered_map< EgtUUID, ToolData> UUIDTDATA_UMAP ;
|
||||
@@ -64,7 +66,8 @@ class ToolsMgr
|
||||
typedef STRUUID_MAP::const_iterator STRUUID_CITER ;
|
||||
|
||||
private :
|
||||
std::string m_sToolsFile ;
|
||||
std::string m_sToolsDir ;
|
||||
std::string m_sToolsPath ;
|
||||
UUIDTDATA_UMAP m_utData ;
|
||||
STRUUID_MAP m_suData ;
|
||||
mutable STRUUID_CITER m_suCIter ;
|
||||
|
||||
Reference in New Issue
Block a user