Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 66466225d4 | |||
| 34ef5388e1 | |||
| a470ffa6ce | |||
| 929c724b9f | |||
| d1ad8fe9c5 | |||
| fb02fa7243 | |||
| bdb93bf21f | |||
| 260b35c7e3 | |||
| 83cbe5b299 | |||
| c6ede73c9e | |||
| 5fca2321af | |||
| f9ebc68077 | |||
| 22aa1cebc8 | |||
| 9d836abbca | |||
| 3f7ad3e961 | |||
| bea99328ab | |||
| baedb87cd1 |
@@ -231,6 +231,10 @@ class MachMgr : public IMachMgr
|
|||||||
bool MdbReload( void) override ;
|
bool MdbReload( void) override ;
|
||||||
bool MdbSave( void) const override ;
|
bool MdbSave( void) const override ;
|
||||||
bool MdbGetMachiningDir( std::string& sMchDir) const override ;
|
bool MdbGetMachiningDir( std::string& sMchDir) const override ;
|
||||||
|
bool MdbExport( const STRVECTOR& vsMachiningsNames, const std::string& sOutFile) const ;
|
||||||
|
bool MdbToBeImported( const std::string& sFile, STRVECTOR& vsMachiningsNames, INTVECTOR& vMachiningsTypes) const ;
|
||||||
|
bool MdbImport( const std::string& sFile, const STRVECTOR& vsMachiningsToImport, const STRVECTOR& vsMachiningsNames,
|
||||||
|
STRVECTOR& vsImported) ;
|
||||||
// Operations : general
|
// Operations : general
|
||||||
int GetOperationCount( void) const override ;
|
int GetOperationCount( void) const override ;
|
||||||
int GetFirstOperation( void) const override ;
|
int GetFirstOperation( void) const override ;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "DllMain.h"
|
#include "DllMain.h"
|
||||||
#include "MachMgr.h"
|
#include "MachMgr.h"
|
||||||
|
#include "/EgtDev/Include/EGnFileUtils.h"
|
||||||
|
|
||||||
using namespace std ;
|
using namespace std ;
|
||||||
|
|
||||||
@@ -416,3 +417,58 @@ MachMgr::MdbGetMachiningDir( string& sMchDir) const
|
|||||||
sMchDir = m_sMachinesDir + "\\" + sMachineName + "\\" + MACHININGS_DIR ;
|
sMchDir = m_sMachinesDir + "\\" + sMachineName + "\\" + MACHININGS_DIR ;
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool
|
||||||
|
MachMgr::MdbExport( const STRVECTOR& vsMachiningsNames, const string& sOutFile) const
|
||||||
|
{
|
||||||
|
if ( vsMachiningsNames.empty())
|
||||||
|
return true ;
|
||||||
|
|
||||||
|
// recupero il gestore di lavorazioni della macchina corrente
|
||||||
|
MachiningsMgr* pMsMgr = GetCurrMachiningsMgr() ;
|
||||||
|
if ( pMsMgr == nullptr)
|
||||||
|
return false ;
|
||||||
|
|
||||||
|
return pMsMgr->Export( vsMachiningsNames, sOutFile) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool
|
||||||
|
MachMgr::MdbToBeImported( const string& sFile, STRVECTOR& vsMachiningsNames, INTVECTOR& vMachiningsTypes) const
|
||||||
|
{
|
||||||
|
if ( ! ExistsFile( sFile)) {
|
||||||
|
LOG_ERROR( GetEMkLogger(), "MdbToBeImported Error : File does not exist") ;
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// recupero il gestore di lavorazioni della macchina corrente
|
||||||
|
MachiningsMgr* pMsMgr = GetCurrMachiningsMgr() ;
|
||||||
|
if ( pMsMgr == nullptr)
|
||||||
|
return false ;
|
||||||
|
|
||||||
|
return pMsMgr->ToBeImported( sFile, vsMachiningsNames, vMachiningsTypes) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool
|
||||||
|
MachMgr::MdbImport( const string& sFile, const STRVECTOR& vsMachiningsToImport, const STRVECTOR& vsMachiningsNames, STRVECTOR& vsImported)
|
||||||
|
{
|
||||||
|
if ( vsMachiningsToImport.empty())
|
||||||
|
return true ;
|
||||||
|
|
||||||
|
if ( ! ExistsFile( sFile)) {
|
||||||
|
LOG_ERROR( GetEMkLogger(), "MdbImport Error : File does not exist") ;
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( vsMachiningsToImport.size() != vsMachiningsNames.size())
|
||||||
|
return false ;
|
||||||
|
|
||||||
|
// recupero il gestore di lavorazioni della macchina corrente
|
||||||
|
MachiningsMgr* pMsMgr = GetCurrMachiningsMgr() ;
|
||||||
|
if ( pMsMgr == nullptr)
|
||||||
|
return false ;
|
||||||
|
|
||||||
|
return pMsMgr->Import( sFile, vsMachiningsToImport, vsMachiningsNames, vsImported) ;
|
||||||
|
}
|
||||||
+315
-8
@@ -311,7 +311,7 @@ MachiningsMgr::LoadGeneral( Scanner& TheScanner, bool& bEnd)
|
|||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
MachiningsMgr::LoadOneMachining( Scanner& TheScanner, bool& bEnd)
|
MachiningsMgr::LoadOneMachining( Scanner& TheScanner, bool& bEnd, MachiningData** ppMch)
|
||||||
{
|
{
|
||||||
// leggo la prossima linea
|
// leggo la prossima linea
|
||||||
string sLine ;
|
string sLine ;
|
||||||
@@ -324,7 +324,7 @@ MachiningsMgr::LoadOneMachining( Scanner& TheScanner, bool& bEnd)
|
|||||||
if ( sLine.front() != '[' || sLine.back() != ']')
|
if ( sLine.front() != '[' || sLine.back() != ']')
|
||||||
return false ;
|
return false ;
|
||||||
Trim( sLine, "[]") ;
|
Trim( sLine, "[]") ;
|
||||||
// separo tipo da contatore
|
// separo tipo da contatore
|
||||||
string sType, sCount ;
|
string sType, sCount ;
|
||||||
SplitFirst( sLine, "_", sType, sCount) ;
|
SplitFirst( sLine, "_", sType, sCount) ;
|
||||||
ToUpper( sType) ;
|
ToUpper( sType) ;
|
||||||
@@ -367,9 +367,13 @@ MachiningsMgr::LoadOneMachining( Scanner& TheScanner, bool& bEnd)
|
|||||||
// verifico di aver letto tutti i campi
|
// verifico di aver letto tutti i campi
|
||||||
bOk = bOk && ( Flag.count() == nSize) ;
|
bOk = bOk && ( Flag.count() == nSize) ;
|
||||||
// salvo i dati della lavorazione
|
// salvo i dati della lavorazione
|
||||||
bOk = bOk && m_umData.emplace( pMch->m_Uuid, Get( pMch)).second ;
|
if ( ppMch == nullptr ) {
|
||||||
bOk = bOk && m_suData.emplace( pMch->m_sName, pMch->m_Uuid).second ;
|
bOk = bOk && m_umData.emplace( pMch->m_Uuid, Get( pMch)).second ;
|
||||||
Release( pMch) ;
|
bOk = bOk && m_suData.emplace( pMch->m_sName, pMch->m_Uuid).second ;
|
||||||
|
Release( pMch) ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
*ppMch = Release( pMch) ;
|
||||||
return bOk ;
|
return bOk ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -438,7 +442,7 @@ MachiningsMgr::Save( bool bCompressed) const
|
|||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
MachiningsMgr::SaveHeader( Writer& TheWriter) const
|
MachiningsMgr::SaveHeader( Writer& TheWriter, const int nTotal) const
|
||||||
{
|
{
|
||||||
// scrivo l'intestazione
|
// scrivo l'intestazione
|
||||||
bool bOk = true ;
|
bool bOk = true ;
|
||||||
@@ -447,7 +451,10 @@ MachiningsMgr::SaveHeader( Writer& TheWriter) const
|
|||||||
bOk = bOk && TheWriter.OutText( sOut) ;
|
bOk = bOk && TheWriter.OutText( sOut) ;
|
||||||
sOut = MF_VERSION + "=" + ToString( m_nDbVer) ;
|
sOut = MF_VERSION + "=" + ToString( m_nDbVer) ;
|
||||||
bOk = bOk && TheWriter.OutText( sOut) ;
|
bOk = bOk && TheWriter.OutText( sOut) ;
|
||||||
sOut = MF_TOTAL + "=" + ToString( int( m_umData.size())) ;
|
if ( nTotal == -1)
|
||||||
|
sOut = MF_TOTAL + "=" + ToString( int( m_umData.size())) ;
|
||||||
|
else
|
||||||
|
sOut = MF_TOTAL + "=" + ToString( nTotal) ;
|
||||||
bOk = bOk && TheWriter.OutText( sOut) ;
|
bOk = bOk && TheWriter.OutText( sOut) ;
|
||||||
return bOk ;
|
return bOk ;
|
||||||
}
|
}
|
||||||
@@ -514,7 +521,7 @@ MachiningsMgr::SaveOneMachining( const EgtUUID& Uuid, int& nCounter, Writer& The
|
|||||||
bool
|
bool
|
||||||
MachiningsMgr::GetMachiningNewName( string& sName) const
|
MachiningsMgr::GetMachiningNewName( string& sName) const
|
||||||
{
|
{
|
||||||
// il parametro nome deve essere valido
|
// il parametro nome deve essere valido
|
||||||
if ( &sName == nullptr)
|
if ( &sName == nullptr)
|
||||||
return false ;
|
return false ;
|
||||||
// se nome vuoto, assegno radice standard
|
// se nome vuoto, assegno radice standard
|
||||||
@@ -1168,3 +1175,303 @@ MachiningsMgr::SetMaxDepthSafe( double dSafe)
|
|||||||
}
|
}
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool
|
||||||
|
MachiningsMgr::Export( const STRVECTOR& vsMachiningsNames, const string& sOutFile, bool bCompressed) const
|
||||||
|
{
|
||||||
|
LOG_INFO( GetEMkLogger(), ( "Export Machinings " + sOutFile).c_str()) ;
|
||||||
|
|
||||||
|
// conto le lavorazioni da esportare
|
||||||
|
int nMachinings = 0 ;
|
||||||
|
for ( size_t i = 0 ; i < vsMachiningsNames.size() ; i ++) {
|
||||||
|
if ( m_suData.find( vsMachiningsNames[i]) != m_suData.end())
|
||||||
|
nMachinings ++ ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// inizializzo il writer
|
||||||
|
Writer TheWriter ;
|
||||||
|
if ( ! TheWriter.Init( sOutFile, bCompressed)) {
|
||||||
|
LOG_ERROR( GetEMkLogger(), " Error Exporting Machinings on Init") ;
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// scrivo linea di inizio file
|
||||||
|
string sOut = "; --- " + sOutFile + " " + CurrDateTime() + " ---" ;
|
||||||
|
if ( ! TheWriter.OutText( sOut)) {
|
||||||
|
LOG_ERROR( GetEMkLogger(), " Error Exporting Machinings on Start") ;
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// scrivo l'intestazione
|
||||||
|
if ( ! SaveHeader( TheWriter, nMachinings)) {
|
||||||
|
LOG_ERROR( GetEMkLogger(), " Error Exporting Machinings on Header") ;
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// scrivo i dati generali
|
||||||
|
if ( m_nDbVer >= 1002 && ! SaveGeneral( TheWriter)) {
|
||||||
|
LOG_ERROR( GetEMkLogger(), " Error Exporting Machinings on General") ;
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ciclo su tutti i nomi delle lavorazioni da esportare
|
||||||
|
int nCounter = 0 ;
|
||||||
|
for ( size_t i = 0 ; i < vsMachiningsNames.size() ; i ++) {
|
||||||
|
auto it = m_suData.find( vsMachiningsNames[i]) ;
|
||||||
|
// se la lavorazione non esiste passo alla sucessiva
|
||||||
|
if ( it == m_suData.end()) {
|
||||||
|
string sOut = " Warning Exporting Machinings : " + vsMachiningsNames[i] + " not found. Machining is ignored." ;
|
||||||
|
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
|
||||||
|
continue ;
|
||||||
|
}
|
||||||
|
// esporto la singola lavorazione
|
||||||
|
if ( ! SaveOneMachining( it->second, nCounter, TheWriter)) {
|
||||||
|
string sOut = " Error Exporting Machining " + it->first ;
|
||||||
|
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// scrivo linea di fine file
|
||||||
|
if ( ! TheWriter.OutText( "; --- End ---")) {
|
||||||
|
LOG_ERROR( GetEMkLogger(), " Error Exporting Machinings on End") ;
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// chiudo la scrittura
|
||||||
|
TheWriter.Close() ;
|
||||||
|
|
||||||
|
return true ;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool
|
||||||
|
MachiningsMgr::ToBeImported( const string& sFile, STRVECTOR& vsMachiningsNames, INTVECTOR& vMachiningsTypes)
|
||||||
|
{
|
||||||
|
// inizializzo lo scanner
|
||||||
|
Scanner TheScanner ;
|
||||||
|
if ( ! TheScanner.Init( sFile, ";")) {
|
||||||
|
LOG_ERROR( GetEMkLogger(), "Machinings ToBeImported : Error on Init") ;
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// leggo l'intestazione
|
||||||
|
int nVersion = 0 ;
|
||||||
|
int nTotal = 0 ;
|
||||||
|
bool bEnd = false ;
|
||||||
|
if ( ! LoadHeader( TheScanner, nVersion, nTotal, bEnd)) {
|
||||||
|
LOG_ERROR( GetEMkLogger(), "Machinings ToBeImported : Error on Header") ;
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
|
|
||||||
|
string sLine ;
|
||||||
|
if ( ! TheScanner.GetLine( sLine))
|
||||||
|
return true ; // il file è finito, esco
|
||||||
|
|
||||||
|
// parte generale
|
||||||
|
if ( sLine == MF_GENERAL) {
|
||||||
|
// scorro le linee fino ad arrivare alla sezione successiva
|
||||||
|
while ( TheScanner.GetLine( sLine)) {
|
||||||
|
if ( sLine.front() == '[' && sLine.back() == ']')
|
||||||
|
break ;
|
||||||
|
}
|
||||||
|
// se non c'è una sezione successiva esco
|
||||||
|
if ( sLine.empty())
|
||||||
|
return true ;
|
||||||
|
}
|
||||||
|
else if ( nVersion >= 1002) {
|
||||||
|
LOG_ERROR( GetEMkLogger(), "Machinings ToBeImported : General section missing") ;
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool bMachiningName = false ;
|
||||||
|
bool bAdd = true ;
|
||||||
|
string sName ;
|
||||||
|
int nType = 0 ;
|
||||||
|
|
||||||
|
TheScanner.UngetLine( sLine) ;
|
||||||
|
while ( TheScanner.GetLine( sLine)) {
|
||||||
|
if ( sLine.front() == '[' && sLine.back() == ']') { // se è intestazione
|
||||||
|
// aggiungo lavorazione precedente se ok
|
||||||
|
if ( bAdd && bMachiningName && nType != 0) {
|
||||||
|
vsMachiningsNames.push_back( sName) ;
|
||||||
|
vMachiningsTypes.push_back( nType) ;
|
||||||
|
}
|
||||||
|
bMachiningName = false ;
|
||||||
|
bAdd = true ;
|
||||||
|
|
||||||
|
// salvo il tipo di lavorazione
|
||||||
|
Trim( sLine, "[]") ;
|
||||||
|
string sType, sCount ;
|
||||||
|
SplitFirst( sLine, "_", sType, sCount) ;
|
||||||
|
ToUpper( sType) ;
|
||||||
|
nType = MCHDATA_NAMETOTYPE( sType) ;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
string sKey, sVal ;
|
||||||
|
SplitFirst( sLine, "=", sKey, sVal) ;
|
||||||
|
if ( ToUpper( sKey) == "NAME") {
|
||||||
|
if ( ! bMachiningName) {
|
||||||
|
bMachiningName = true ;
|
||||||
|
sName = sVal ;
|
||||||
|
}
|
||||||
|
else // se lavorazione ha più nomi è errore, non deve essere importata
|
||||||
|
bAdd = false ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// aggiungo ultima lavorazione se ok
|
||||||
|
if ( bAdd && bMachiningName && nType != 0) {
|
||||||
|
vsMachiningsNames.push_back( sName) ;
|
||||||
|
vMachiningsTypes.push_back( nType) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( vsMachiningsNames.size() != vMachiningsTypes.size())
|
||||||
|
return false ;
|
||||||
|
|
||||||
|
return true ;
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool
|
||||||
|
MachiningsMgr::Import( const string& sFile, const STRVECTOR& vsMachiningsToImport, const STRVECTOR& vsMachiningsNames, STRVECTOR& vsImported)
|
||||||
|
{
|
||||||
|
LOG_INFO( GetEMkLogger(), ( "Import Machinings : " + sFile).c_str()) ;
|
||||||
|
|
||||||
|
for ( size_t i = 0 ; i < vsMachiningsNames.size() ; i ++) {
|
||||||
|
// se esiste già nel DB una lavorazione con lo stesso nome la rimuovo
|
||||||
|
if ( m_suData.find( vsMachiningsNames[i]) != m_suData.end()) {
|
||||||
|
bool bOk = RemoveMachining( vsMachiningsNames[i]) ;
|
||||||
|
if ( ! bOk) {
|
||||||
|
LOG_ERROR( GetEMkLogger(), ( " Error Importing Machinings : removing " + vsMachiningsNames[i] + " failed" ).c_str()) ;
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// verfico che il nome non sia ripetuto nella lista dei vsMachiningsNames
|
||||||
|
if ( i != vsMachiningsNames.size() - 1 &&
|
||||||
|
find( vsMachiningsNames.begin() + i + 1, vsMachiningsNames.end(), vsMachiningsNames[i]) != vsMachiningsNames.end()) {
|
||||||
|
LOG_ERROR( GetEMkLogger(), ( " Error Importing Machinings : name \"" + vsMachiningsNames[i] + "\" is already used").c_str()) ;
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// inizializzo lo scanner
|
||||||
|
Scanner TheScanner ;
|
||||||
|
if ( ! TheScanner.Init( sFile, ";")) {
|
||||||
|
LOG_ERROR( GetEMkLogger(), " Error Importing Machinings on Init") ;
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// leggo l'intestazione
|
||||||
|
int nVersion = 0 ;
|
||||||
|
int nTotal = 0 ;
|
||||||
|
bool bEnd ;
|
||||||
|
if ( ! LoadHeader( TheScanner, nVersion, nTotal, bEnd)) {
|
||||||
|
LOG_ERROR( GetEMkLogger(), " Error Importing Machinings on Header") ;
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// leggo i dati generali (da versione 1002) e li confronto con quelli della classe
|
||||||
|
if ( nVersion >= 1002 && ! CheckGeneral( TheScanner, bEnd)) {
|
||||||
|
LOG_ERROR( GetEMkLogger(), " Error Importing Machinings on General") ;
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ciclo di lettura delle lavorazioni
|
||||||
|
while ( ! bEnd) {
|
||||||
|
MachiningData* pMch = nullptr ;
|
||||||
|
if ( ! LoadOneMachining( TheScanner, bEnd, &pMch) || pMch == nullptr)
|
||||||
|
// se errore nel leggere la lavorazione, proseguo con la successiva
|
||||||
|
continue ;
|
||||||
|
|
||||||
|
auto it = find( vsMachiningsToImport.begin(), vsMachiningsToImport.end(), pMch->m_sName) ;
|
||||||
|
// se la lavorazione non deve essere importata proseguo con la successiva
|
||||||
|
if ( it == vsMachiningsToImport.end())
|
||||||
|
continue ;
|
||||||
|
|
||||||
|
// assegno il nuovo nome
|
||||||
|
pMch->m_sName = vsMachiningsNames[ it - vsMachiningsToImport.begin()] ;
|
||||||
|
// se il suo UUID esiste già nel DB lo modifico
|
||||||
|
if ( m_umData.find( pMch->m_Uuid) != m_umData.end()) {
|
||||||
|
LOG_ERROR( GetEMkLogger(), ( " Warning Importing Machinings: " + pMch->m_sName + " UUID changed").c_str()) ;
|
||||||
|
CreateEgtUUID( pMch->m_Uuid) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// aggiungo la lavorazione
|
||||||
|
bool bOk = m_umData.emplace( pMch->m_Uuid, pMch).second ;
|
||||||
|
bOk = bOk && m_suData.emplace( pMch->m_sName, pMch->m_Uuid).second ;
|
||||||
|
if ( ! bOk) {
|
||||||
|
LOG_ERROR( GetEMkLogger(), ( " Error Importing Machinings : adding " + pMch->m_sName + " failed" ).c_str()) ;
|
||||||
|
continue ;
|
||||||
|
}
|
||||||
|
vsImported.push_back( pMch->m_sName) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! vsImported.empty())
|
||||||
|
m_bModified = true ;
|
||||||
|
|
||||||
|
return true ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool
|
||||||
|
MachiningsMgr::CheckGeneral( Scanner& TheScanner, bool& bEnd) const
|
||||||
|
{
|
||||||
|
// leggo la prossima linea
|
||||||
|
string sLine ;
|
||||||
|
if ( ! TheScanner.GetLine( sLine)) {
|
||||||
|
// fine file
|
||||||
|
bEnd = true ;
|
||||||
|
return true ;
|
||||||
|
}
|
||||||
|
// deve essere dati generali
|
||||||
|
if ( sLine != MF_GENERAL)
|
||||||
|
return false ;
|
||||||
|
bool bOk = true ;
|
||||||
|
// leggo le linee successive
|
||||||
|
bEnd = true ;
|
||||||
|
while ( bOk && TheScanner.GetLine( sLine)) {
|
||||||
|
// se sezione successiva
|
||||||
|
if ( sLine.front() == '[' && sLine.back() == ']') {
|
||||||
|
TheScanner.UngetLine( sLine) ;
|
||||||
|
bEnd = false ;
|
||||||
|
break ;
|
||||||
|
}
|
||||||
|
// separo chiave da valore
|
||||||
|
string sKey, sVal ;
|
||||||
|
bool bVal ;
|
||||||
|
int nVal ;
|
||||||
|
double dVal ;
|
||||||
|
SplitFirst( sLine, "=", sKey, sVal) ;
|
||||||
|
// riconosco la chiave e verifico che il valore corrisponda a quello salvato nella classe
|
||||||
|
if ( ToUpper( sKey) == MF_3AXCOMP)
|
||||||
|
bOk = FromString( sVal, bVal) && bVal == m_b3AxComp ;
|
||||||
|
else if ( ToUpper( sKey) == MF_5AXCOMP)
|
||||||
|
bOk = FromString( sVal, bVal) && bVal == m_b5AxComp ;
|
||||||
|
else if ( ToUpper( sKey) == MF_SAFEZ)
|
||||||
|
bOk = FromString( sVal, dVal) && abs( m_dSafeZ - dVal) < EPS_SMALL ;
|
||||||
|
else if ( ToUpper( sKey) == MF_SAFEAGGRBOTTZ)
|
||||||
|
bOk = FromString( sVal, dVal) && abs( m_dSafeAggrBottZ - dVal) < EPS_SMALL ;
|
||||||
|
else if ( ToUpper( sKey) == MF_EXTRALCR)
|
||||||
|
bOk = FromString( sVal, dVal) && abs( m_dExtraLOnCutRegion - dVal) < EPS_SMALL ;
|
||||||
|
else if ( ToUpper( sKey) == MF_EXTRARDR)
|
||||||
|
bOk = FromString( sVal, dVal) && abs( m_dExtraROnDrillRegion - dVal) < EPS_SMALL ;
|
||||||
|
else if ( ToUpper( sKey) == MF_HOLEDTOL)
|
||||||
|
bOk = FromString( sVal, dVal) && abs( m_dHoleDiamToler - dVal) < EPS_SMALL ;
|
||||||
|
else if ( ToUpper( sKey) == MF_EXTSAWARCMINRAD)
|
||||||
|
bOk = FromString( sVal, dVal) && abs( m_dExtSawArcMinRad - dVal) < EPS_SMALL ;
|
||||||
|
else if ( ToUpper( sKey) == MF_INTSAWARCMAXSIDEANG)
|
||||||
|
bOk = FromString( sVal, dVal) && abs( m_dIntSawArcMaxSideAng - dVal) < EPS_SMALL ;
|
||||||
|
else if ( ToUpper( sKey) == MF_SPLITARCS)
|
||||||
|
bOk = FromString( sVal, nVal) && m_nSplitArcs == nVal ;
|
||||||
|
else if ( ToUpper( sKey) == MF_MAXDEPTHSAFE)
|
||||||
|
bOk = FromString( sVal, dVal) && abs( m_dMaxDepthSafe - dVal) < EPS_SMALL ;
|
||||||
|
else
|
||||||
|
bOk = true ;
|
||||||
|
}
|
||||||
|
|
||||||
|
return bOk ;
|
||||||
|
}
|
||||||
+6
-2
@@ -29,6 +29,9 @@ class MachiningsMgr
|
|||||||
bool Load( const std::string& sMachsFile, const ToolsMgr* pTsMgr) ;
|
bool Load( const std::string& sMachsFile, const ToolsMgr* pTsMgr) ;
|
||||||
bool Reload( void) ;
|
bool Reload( void) ;
|
||||||
bool Save( bool bCompressed = true) const ;
|
bool Save( bool bCompressed = true) const ;
|
||||||
|
bool Export( const STRVECTOR& vsMachiningsNames, const std::string& sOutFile, bool bCompressed = true) const ;
|
||||||
|
bool ToBeImported( const std::string& sFile, STRVECTOR& vsMachiningsNames, INTVECTOR& vMachiningsTypes) ;
|
||||||
|
bool Import( const std::string& sFile, const STRVECTOR& vsMachiningsToImport, const STRVECTOR& vsMachiningsNames, STRVECTOR& vsImported) ;
|
||||||
bool GetMachiningNewName( std::string& sName) const ;
|
bool GetMachiningNewName( std::string& sName) const ;
|
||||||
bool AddMachining( const std::string& sName, int nType) ;
|
bool AddMachining( const std::string& sName, int nType) ;
|
||||||
bool CopyMachining( const std::string& sSource, const std::string& sName) ;
|
bool CopyMachining( const std::string& sSource, const std::string& sName) ;
|
||||||
@@ -86,8 +89,9 @@ class MachiningsMgr
|
|||||||
bool Clear( bool bReset) ;
|
bool Clear( bool bReset) ;
|
||||||
bool LoadHeader( Scanner& TheScanner, int& nVersion, int& nTotal, bool& bEnd) ;
|
bool LoadHeader( Scanner& TheScanner, int& nVersion, int& nTotal, bool& bEnd) ;
|
||||||
bool LoadGeneral( Scanner& TheScanner, bool& bEnd) ;
|
bool LoadGeneral( Scanner& TheScanner, bool& bEnd) ;
|
||||||
bool LoadOneMachining( Scanner& TheScanner, bool& bEnd) ;
|
bool CheckGeneral( Scanner& TheScanner, bool& bEnd) const ;
|
||||||
bool SaveHeader( Writer& TheWriter) const ;
|
bool LoadOneMachining( Scanner& TheScanner, bool& bEnd, MachiningData** ppMch = nullptr) ;
|
||||||
|
bool SaveHeader( Writer& TheWriter, const int nTotal = -1) const ;
|
||||||
bool SaveGeneral( Writer& TheWriter) const ;
|
bool SaveGeneral( Writer& TheWriter) const ;
|
||||||
bool SaveOneMachining( const EgtUUID& Uuid, int& nCounter, Writer& TheWriter) const ;
|
bool SaveOneMachining( const EgtUUID& Uuid, int& nCounter, Writer& TheWriter) const ;
|
||||||
bool VerifyCurrMachining( int nType, std::string& sName) const ;
|
bool VerifyCurrMachining( int nType, std::string& sName) const ;
|
||||||
|
|||||||
+1798
-1008
File diff suppressed because it is too large
Load Diff
+36
-27
@@ -18,6 +18,7 @@
|
|||||||
#include "ToolData.h"
|
#include "ToolData.h"
|
||||||
#include "/EgtDev/Include/EGkCurveComposite.h"
|
#include "/EgtDev/Include/EGkCurveComposite.h"
|
||||||
#include "/EgtDev/Include/EgtNumUtils.h"
|
#include "/EgtDev/Include/EgtNumUtils.h"
|
||||||
|
#include "/EgtDev/Include/EGkSurfFlatRegion.h"
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
class Pocketing : public Machining
|
class Pocketing : public Machining
|
||||||
@@ -70,46 +71,54 @@ class Pocketing : public Machining
|
|||||||
bool SetCurveAllTempProp( int nCrvId, ICurve* pCurve) ;
|
bool SetCurveAllTempProp( int nCrvId, ICurve* pCurve) ;
|
||||||
bool ResetCurveAllTempProp( ICurve* pCurve) ;
|
bool ResetCurveAllTempProp( ICurve* pCurve) ;
|
||||||
bool Chain( int nGrpDestId) ;
|
bool Chain( int nGrpDestId) ;
|
||||||
bool ProcessPath( int nPathId, int nPvId, int nClId) ;
|
bool ProcessPath( int nAuxId, int nPvId, int nClId) ;
|
||||||
bool CalcRegionElevation( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dRad, double& dElev) const ;
|
bool CalcRegionElevation( const ICurveComposite* pCompo, const Vector3d& vtTool, double dDepth, double dRad, double& dElev) const ;
|
||||||
bool VerifyPathFromBottom( const ICurveComposite* pCompo, const Vector3d& vtTool) ;
|
bool VerifyPathFromBottom( const ICurveComposite* pCompo, const Vector3d& vtTool) ;
|
||||||
bool GeneratePocketingPv( int nPathId, const ICurveComposite* pCompo) ;
|
bool GeneratePocketingPv( int nPathId, const ISurfFlatRegion* pSrf) ;
|
||||||
bool AddZigZag( const ICurveComposite* pCompo, const Vector3d& vtTool, const Vector3d& vtExtr,
|
bool AddZigZag( const ISurfFlatRegion* pSrf, const Vector3d& vtTool, const Vector3d& vtExtr,
|
||||||
double dDepth, double dElev, double dOkStep, bool bSplitArcs) ;
|
double dDepth, double dElev, double dOkStep, bool bSplitArcs) ;
|
||||||
bool CalcZigZag( const ICurveComposite* pOffs, ICRVCOMPOPOVECTOR& vpCrvs) ;
|
bool CalcZigZag( const ISurfFlatRegion* pSrf, ICRVCOMPOPOVECTOR& vpCrvs) ;
|
||||||
bool AddOneWay( const ICurveComposite* pCompo, const Vector3d& vtTool, const Vector3d& vtExtr,
|
bool AddOneWay( const ISurfFlatRegion* pSrf, const Vector3d& vtTool, const Vector3d& vtExtr,
|
||||||
double dDepth, double dElev, double dOkStep, bool bSplitArcs) ;
|
double dDepth, double dElev, double dOkStep, bool bSplitArcs) ;
|
||||||
bool AddSpiralIn( const ICurveComposite* pCompo, const Vector3d& vtTool, const Vector3d& vtExtr,
|
bool AddSpiralIn( const ISurfFlatRegion* pSrf, const Vector3d& vtTool, const Vector3d& vtExtr,
|
||||||
double dDepth, double dElev, double dOkStep, bool bSplitArcs, bool bMidOpen,
|
double dDepth, double dElev, double dOkStep, bool bSplitArcs, bool bMidOpen,
|
||||||
const Point3d& ptMidOpen, const Vector3d& vtMidOut) ;
|
const Point3d& ptMidOpen, const Vector3d& vtMidOut) ;
|
||||||
bool AddSpiralOut( const ICurveComposite* pCompo, const Vector3d& vtTool, const Vector3d& vtExtr,
|
bool AddSpiralOut( const ISurfFlatRegion* pSrf, const Vector3d& vtTool, const Vector3d& vtExtr,
|
||||||
double dDepth, double dElev, double dOkStep, bool bSplitArcs) ;
|
double dDepth, double dElev, double dOkStep, bool bSplitArcs) ;
|
||||||
bool CalcSpiral( const ICurveComposite* pCompo, int nReg, bool bSplitArcs,
|
bool CalcSpiral( const ISurfFlatRegion* pSrf, int nReg, bool bSplitArcs,
|
||||||
ICurveComposite* pMCrv, ICurveComposite* pRCrv) ;
|
ICurveComposite* pMCrv, ICurveComposite* pRCrv) ;
|
||||||
bool CalcBoundedLink( const Point3d& ptStart, const Point3d& ptEnd, const ICurve* pCrvBound,
|
bool RemoveUncutRegions( const ISurfFlatRegion * pCutRegion, ICRVCOMPOPVECTOR& vOffs, const ISurfFlatRegion * pSrfBound) ;
|
||||||
ICurveComposite* pCrvLink) ;
|
bool FindCurveForPathAdd( const ICurve* pResidualCrv, const ICRVCOMPOPOVECTOR& vOffs, size_t& nIdxMin, Point3d& ptMinDist,
|
||||||
|
double& dMinDistPar, const ISurfFlatRegion * pSrfBound) ;
|
||||||
|
bool ComputeAdditionalPath( const Point3d ptStart, Point3d ptEnd, bool bUsePtEnd, ICurveComposite * pAddPath,
|
||||||
|
const ICurve * pResidualCrv, const ISurfFlatRegion * pSrfBound, ISurfFlatRegion * pNewCutRegion) ;
|
||||||
|
bool AdditionalPathExternalCentroid( const Point3d ptStart, ICurveComposite * pAddPath, ICurveComposite * pResidualCrv,
|
||||||
|
const ISurfFlatRegion * pSrfBound, ISurfFlatRegion * pNewCutRegion) ;
|
||||||
|
bool CalcBoundedLink( const Point3d& ptStart, const Point3d& ptEnd, const ISurfFlatRegion * pSrf,
|
||||||
|
ICurveComposite* pCrvLink) ;
|
||||||
|
bool CircleSpiral( ISurfFlatRegion* pSrf, bool bSplitArcs, ICRVCOMPOPVECTOR& vOffs, ICurveComposite* pRCrv) ;
|
||||||
bool CalcCircleSpiral( const Point3d& ptCen, const Vector3d& vtN, double dOutRad, double dIntRad,
|
bool CalcCircleSpiral( const Point3d& ptCen, const Vector3d& vtN, double dOutRad, double dIntRad,
|
||||||
bool bSplitArcs, ICurveComposite* pMCrv, ICurveComposite* pRCrv) ;
|
bool bSplitArcs, ICurveComposite* pMCrv, ICurveComposite* pRCrv) ;
|
||||||
bool AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dSafeAggrBottZ,
|
bool AddApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dSafeAggrBottZ,
|
||||||
double dElev, double dAppr, bool bOutStart) ;
|
double dElev, double dAppr, bool bOutStart) ;
|
||||||
bool AddLinkApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dSafeAggrBottZ,
|
bool AddLinkApproach( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dSafeAggrBottZ,
|
||||||
double dElev, double dAppr) ;
|
double dElev, double dAppr) ;
|
||||||
bool AddLinkRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dSafeAggrBottZ,
|
bool AddLinkRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dSafeAggrBottZ,
|
||||||
double dElev, double dAppr) ;
|
double dElev, double dAppr) ;
|
||||||
bool AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dSafeAggrBottZ,
|
bool AddRetract( const Point3d& ptP, const Vector3d& vtTool, double dSafeZ, double dSafeAggrBottZ,
|
||||||
double dElev, double dAppr) ;
|
double dElev, double dAppr) ;
|
||||||
bool CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtN,
|
bool CalcLeadInStart( const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtN,
|
||||||
const ICurveComposite* pRCrv, Point3d& ptP1) const ;
|
const ICurveComposite* pRCrv, Point3d& ptP1) const ;
|
||||||
bool AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtN,
|
bool AddLeadIn( const Point3d& ptP1, const Point3d& ptStart, const Vector3d& vtStart, const Vector3d& vtN,
|
||||||
const ICurveComposite* pCompo, const ICurveComposite* pRCrv, bool bAtLeft, bool bSplitArcs, bool bNoneForced = false) ;
|
const ISurfFlatRegion* pSrf, const ICurveComposite* pRCrv, bool bAtLeft, bool bSplitArcs, bool bNoneForced = false) ;
|
||||||
bool AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d& vtN,
|
bool AddLeadOut( const Point3d& ptEnd, const Vector3d& vtEnd, const Vector3d& vtN,
|
||||||
const ICurveComposite* pRCrv, bool bSplitArcs, Point3d& ptP1, double& dElev, bool bNoneForced = false) ;
|
const ICurveComposite* pRCrv, bool bSplitArcs, Point3d& ptP1, double& dElev, bool bNoneForced = false) ;
|
||||||
double GetRadiusForStartEndElevation( void) const ;
|
double GetRadiusForStartEndElevation( void) const ;
|
||||||
bool GetMidOfLongestOpenSide( const ICurveComposite* pCompo, Point3d& ptMid, Vector3d& vtMidOut) ;
|
bool GetMidOfLongestOpenSide( const ICurveComposite* pCompo, Point3d& ptMid, Vector3d& vtMidOut) ;
|
||||||
bool AdjustContourWithOpenEdges( ICurveComposite* pCompo) ;
|
bool AdjustContourWithOpenEdges( ICurveComposite* pCompo) ;
|
||||||
bool AdjustContourStart( ICurveComposite* pCompo) ;
|
bool AdjustContourStart( ICurveComposite* pCompo) ;
|
||||||
bool VerifyLeadInHelix( const ICurveComposite* pCompo, const Point3d& ptCen, double dRad) const ;
|
bool VerifyLeadInHelix( const ISurfFlatRegion* pSrf, const Point3d& ptCen, double dRad) const ;
|
||||||
bool VerifyLeadInZigZag( const ICurveComposite* pCompo, const Point3d& ptPa, const Point3d& ptPb) const ;
|
bool VerifyLeadInZigZag( const ISurfFlatRegion* pSrf, const Point3d& ptPa, const Point3d& ptPb) const ;
|
||||||
|
|
||||||
private :
|
private :
|
||||||
double GetSpeed( void) const
|
double GetSpeed( void) const
|
||||||
|
|||||||
Reference in New Issue
Block a user