EgtMachKernel :

- aggiunta ImportSetup.
This commit is contained in:
Dario Sassi
2017-01-28 07:56:32 +00:00
parent 5ffbaab0e4
commit 0bafc660b5
5 changed files with 175 additions and 6 deletions
+12
View File
@@ -60,12 +60,24 @@ const std::string TOOLHOLDERS_DIR = "THolders" ;
// Nome file degli utensili
const std::string TOOLS_FILE = "Tools.data" ;
//----------------------------------------------------------------------------
// Nome sottodirettorio degli attrezzaggi
const std::string SETUP_DIR = "Setup" ;
// Nome estensione dei setup
const std::string SETUP_EXT = "stu" ;
//----------------------------------------------------------------------------
// Nome sottodirettorio delle lavorazioni
const std::string MACHININGS_DIR = "Machinings" ;
// Nome file delle lavorazioni
const std::string MACHININGS_FILE = "Machinings.data" ;
//----------------------------------------------------------------------------
// Sezione di attrezzaggio nel file INI di macchina
const std::string SETUP_SEC = "Setup" ;
// Chaive per attrezzaggio di default
const std::string SETUP_DEF_KEY = "Default" ;
//----------------------------------------------------------------------------
// Minimo spessore del grezzo
const double RAW_MIN_H = 1 ;
+6 -3
View File
@@ -84,8 +84,6 @@ class MachMgr : public IMachMgr
bool SetCurrMachGroup( int nId) override ;
bool ResetCurrMachGroup( void) override ;
int GetCurrMachGroup( void) const override ;
// Setup
int GetCurrSetup( void) const override ;
// Phases
int AddPhase( void) override ;
bool SetCurrPhase( int nPhase, bool bForced = false) override ;
@@ -159,6 +157,9 @@ class MachMgr : public IMachMgr
bool TdbSave( void) const override ;
bool TdbGetToolDir( std::string& sToolDir) const override ;
bool TdbGetToolHolderDir( std::string& sTHolderDir) const override ;
// Setup
int GetCurrSetup( void) const override ;
bool ImportSetup( const std::string& sName) override ;
// Machinings DataBase
bool MdbGetMachiningNewName( std::string& sName) const override ;
bool MdbAddMachining( const std::string& sName, int nType) ;
@@ -308,8 +309,10 @@ class MachMgr : public IMachMgr
// MachGroups
std::string GetCurrMGeoName( void) const
{ return ( ExistsCurrMachGroup() ? m_cCurrMGrp.MGeoName : "") ; }
std::string GetCurrSetupDir( void) const
{ return ( ExistsCurrMachGroup() ? m_sMachinesDir + "\\" + m_cCurrMGrp.MGeoName + "\\" + SETUP_DIR : "") ; }
std::string GetCurrFixtDir( void) const
{ return ( ExistsCurrMachGroup() ? m_sMachinesDir+"\\"+m_cCurrMGrp.MGeoName+"\\"+FIXTURES_DIR : "") ; }
{ return ( ExistsCurrMachGroup() ? m_sMachinesDir + "\\" + m_cCurrMGrp.MGeoName + "\\" + FIXTURES_DIR : "") ; }
int GetCurrSetupGroupId( void) const
{ return ( ExistsCurrMachGroup() ? m_cCurrMGrp.SetupGroupId : GDB_ID_NULL) ; }
int GetCurrFixtGroupId( void) const
+33
View File
@@ -15,6 +15,7 @@
#include "stdafx.h"
#include "DllMain.h"
#include "MachMgr.h"
#include "/EgtDev/Include/EgtIniFile.h"
using namespace std ;
@@ -24,3 +25,35 @@ MachMgr::GetCurrSetup( void) const
{
return GetCurrSetupGroupId() ;
}
//----------------------------------------------------------------------------
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 sMachIni = m_sMachinesDir + "\\" + GetCurrMGeoName() + "\\" + GetCurrMGeoName() + ".ini" ;
string sDefault = GetPrivateProfileStringUtf8( SETUP_SEC.c_str(), SETUP_DEF_KEY.c_str(), "", sMachIni.c_str()) ;
if ( ! IsEmptyOrSpaces( sDefault))
sFileName += sDefault + "." + SETUP_EXT ;
else
return false ;
}
// gestione attrezzaggio
SetupMgr stuMgr ;
stuMgr.Init( this) ;
// importo l'attrezzaggio
if ( ! stuMgr.Import( sFileName))
return false ;
// lo inserisco nel progetto
return stuMgr.Save() ;
}
+120 -1
View File
@@ -16,12 +16,16 @@
#include "SetupMgr.h"
#include "DllMain.h"
#include "MachMgr.h"
#include "/EgtDEv/Include/EGnScanner.h"
using namespace std ;
//----------------------------------------------------------------------------
SetupMgr::SetupMgr( void)
{
m_pMchMgr = nullptr ;
m_pGeomDB = nullptr ;
m_pMachine = nullptr ;
}
//----------------------------------------------------------------------------
@@ -80,7 +84,122 @@ SetupMgr::Load( void)
if ( vsTok3.size() >= 2) {
if ( FromString( vsTok3[0], stuData.m_nExit) &&
m_pMchMgr->TdbGetToolFromUUID( vsTok3[1], stuData.m_sName)) {
bAdded = true ;
bAdded = true ;
stuData.m_sTuuid = vsTok3[1] ;
m_vStuData.emplace_back( stuData) ;
}
}
}
}
if ( ! bAdded) {
stuData.m_nExit = 0 ;
m_vStuData.emplace_back( stuData) ;
}
// passo alla successiva posizione
++ nPos ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
SetupMgr::Save( void) const
{
// verifico ci sia una macchinata corrente
if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr || m_pMachine == nullptr ||
m_pMchMgr->GetCurrMachGroup() == GDB_ID_NULL)
return false ;
// recupero il gruppo di setup
int nSetupId = m_pMchMgr->GetCurrSetupGroupId() ;
// cancello eventuali campi di attrezzaggio già presenti
int nPosiz = 1 ;
while ( m_pGeomDB->ExistsInfo( nSetupId, "Pos" + ToString( nPosiz))) {
m_pGeomDB->RemoveInfo( nSetupId, "Pos" + ToString( nPosiz)) ;
++ nPosiz ;
}
// eseguo la scrittura dei campi di attrezzaggio
int nSize = int( m_vStuData.size()) ;
int nI = 0 ;
int nPos = 1 ;
while ( nI < nSize) {
// assegno i dati della posizione (Tn;Hm;1/Tuuid/Name,2/Tuuid/Name...)
string sVal ;
sVal = m_vStuData[nI].m_sTcPos ;
if ( m_vStuData[nI].m_nExit > 0)
sVal += ";" + m_vStuData[nI].m_sHead + ";" + ToString( m_vStuData[nI].m_nExit) + "/" +
m_vStuData[nI].m_sTuuid + "/" + m_vStuData[nI].m_sName ;
++ nI ;
// verifico se ci sono altri utensili nella medesima posizione
while ( nI < nSize && m_vStuData[nI].m_sTcPos == m_vStuData[nI-1].m_sTcPos) {
if ( m_vStuData[nI].m_nExit > 0)
sVal += "," + ToString( m_vStuData[nI].m_nExit) + "/" + m_vStuData[nI].m_sTuuid + "/" + m_vStuData[nI].m_sName ;
++ nI ;
}
// scrivo una nuova posizione di attrezzaggio
if ( ! m_pGeomDB->SetInfo( nSetupId, "Pos" + ToString( nPos), sVal))
return false ;
// passo alla successiva posizione
++ nPos ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
SetupMgr::Import( const string& sFileName)
{
// reset
m_vStuData.clear() ;
// verifico ci sia una macchinata corrente
if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr || m_pMachine == nullptr ||
m_pMchMgr->GetCurrMachGroup() == GDB_ID_NULL)
return false ;
// recupero il gruppo di setup
int nSetupId = m_pMchMgr->GetCurrSetupGroupId() ;
// inizializzo lo scanner
Scanner TheScanner ;
if ( ! TheScanner.Init( sFileName, ";"))
return false ;
// eseguo la lettura dei campi di attrezzaggio
int nPos = 1 ;
string sLine ;
while ( TheScanner.GetLine( sLine)) {
// salto dichiarazione sezione
if ( sLine.front() == '[')
continue ;
// recupero i dati della posizione (Posxx=Tn;Hm;1/Tuuid/Name,2/Tuuid/Name...)
size_t nInd = sLine.find( "=") ;
if ( nInd != string::npos)
sLine.erase( 0, nInd + 1) ;
STRVECTOR vsTok1 ;
Tokenize( sLine, ";", vsTok1) ;
if ( vsTok1.empty())
break ;
bool bAdded = false ;
SetupData stuData ;
stuData.m_sTcPos = vsTok1[0] ;
if ( vsTok1.size() >= 3) {
stuData.m_sHead = vsTok1[1] ;
STRVECTOR vsTok2 ;
Tokenize( vsTok1[2], ",", vsTok2) ;
for ( size_t i = 0 ; i < vsTok2.size() ; ++ i) {
STRVECTOR vsTok3 ;
Tokenize( vsTok2[i], "/", vsTok3) ;
if ( vsTok3.size() >= 2) {
if ( FromString( vsTok3[0], stuData.m_nExit) &&
m_pMchMgr->TdbGetToolFromUUID( vsTok3[1], stuData.m_sName)) {
bAdded = true ;
stuData.m_sTuuid = vsTok3[1] ;
m_vStuData.emplace_back( stuData) ;
}
}
+4 -2
View File
@@ -26,11 +26,12 @@ struct SetupData
std::string m_sTcPos ; // posizione in macchina
std::string m_sHead ; // testa macchina
int m_nExit ; // uscita sulla testa
std::string m_sTuuid ; // identificativo universale dell'utensile
std::string m_sName ; // nome dell'utensile attrezzato
SetupData( void) : m_nExit( 0) {}
SetupData( const std::string& sTcPos, const std::string& sHead, int nExit, const std::string& sName)
{ m_sTcPos = sTcPos ; m_sHead = sHead ; m_nExit = nExit ; m_sName = sName ;}
SetupData( const std::string& sTcPos, const std::string& sHead, int nExit, const std::string& Tuuid, const std::string& sName)
{ m_sTcPos = sTcPos ; m_sHead = sHead ; m_nExit = nExit ; m_sTuuid = Tuuid ; m_sName = sName ; }
} ;
//----------------------------------------------------------------------------
@@ -41,6 +42,7 @@ class SetupMgr
bool Init( MachMgr* pMchMgr) ;
bool Load( void) ;
bool Save( void) const ;
bool Import( const std::string& sFileName) ;
bool Exists( void)
{ return ! m_vStuData.empty() ; }
bool FindTool( const std::string& sName) ;