EgtMachKernel :
- aggiunte in interfaccia funzioni per export/import lavorazioni - modifiche varie in export/import utensili e lavorazioni.
This commit is contained in:
+69
-53
@@ -112,7 +112,19 @@ ToolsMgr::Reload( void)
|
||||
|
||||
// ciclo di lettura degli utensili
|
||||
do {
|
||||
if ( ! LoadOneTool( TheScanner, nToolSize, bEnd)) {
|
||||
ToolData tData ;
|
||||
if ( LoadOneTool( TheScanner, nToolSize, tData, bEnd)) {
|
||||
if ( ! tData.m_sName.empty()) {
|
||||
// salvo i dati dell'utensile
|
||||
if ( ! m_utData.emplace( tData.m_Uuid, tData).second ||
|
||||
! m_suData.emplace( tData.m_sName, tData.m_Uuid).second) {
|
||||
bOk = false ;
|
||||
string sOut = "ReloadTools : Error adding tool " + tData.m_sName ;
|
||||
LOG_ERROR( GetEMkLogger(), sOut.c_str())
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
bOk = false ;
|
||||
string sOut = "ReloadTools : Error on line " + ToString( TheScanner.GetCurrLineNbr()) ;
|
||||
LOG_ERROR( GetEMkLogger(), sOut.c_str())
|
||||
@@ -133,7 +145,7 @@ ToolsMgr::Reload( void)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ToolsMgr::LoadHeader( Scanner& TheScanner, int& nVersion, int& nToolSize, int& nTotal, bool& bEnd)
|
||||
ToolsMgr::LoadHeader( Scanner& TheScanner, int& nVersion, int& nToolSize, int& nTotal, bool& bEnd) const
|
||||
{
|
||||
// leggo la prossima linea
|
||||
string sLine ;
|
||||
@@ -176,12 +188,12 @@ ToolsMgr::LoadHeader( Scanner& TheScanner, int& nVersion, int& nToolSize, int& n
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ToolsMgr::LoadOneTool( Scanner& TheScanner, int nToolSize, bool& bEnd)
|
||||
ToolsMgr::LoadOneTool( Scanner& TheScanner, int nToolSize, ToolData& tData, bool& bEnd) const
|
||||
{
|
||||
ToolData tData ;
|
||||
// leggo la prossima linea
|
||||
string sLine ;
|
||||
if ( ! TheScanner.GetLine( sLine)) {
|
||||
tData.m_sName = "" ;
|
||||
// fine file
|
||||
bEnd = true ;
|
||||
return true ;
|
||||
@@ -213,9 +225,6 @@ ToolsMgr::LoadOneTool( Scanner& TheScanner, int nToolSize, bool& bEnd)
|
||||
}
|
||||
// verifico di aver letto tutti i campi
|
||||
bOk = bOk && ( Flag.count() == nToolSize) ;
|
||||
// salvo i dati dell'utensile
|
||||
bOk = bOk && m_utData.emplace( tData.m_Uuid, tData).second ;
|
||||
bOk = bOk && m_suData.emplace( tData.m_sName, tData.m_Uuid).second ;
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
@@ -781,7 +790,7 @@ ToolsMgr::GetCurrToolThLength( double& dThLen) const
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ToolsMgr::Export( const STRVECTOR& vsToolsNames, const string& sOutFile, bool bCompressed)
|
||||
ToolsMgr::Export( const STRVECTOR& vsToolsNames, const string& sOutFile, bool bCompressed) const
|
||||
{
|
||||
LOG_INFO( GetEMkLogger(), ( "Export Tools " + sOutFile).c_str()) ;
|
||||
|
||||
@@ -845,7 +854,7 @@ ToolsMgr::Export( const STRVECTOR& vsToolsNames, const string& sOutFile, bool bC
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ToolsMgr::ExportOneTool( const string& sToolName, Writer& TheWriter, const int& nCounter, const string& sOutDir)
|
||||
ToolsMgr::ExportOneTool( const string& sToolName, Writer& TheWriter, int nCounter, const string& sOutDir) const
|
||||
{
|
||||
// se il tool non esiste nel DB lo ignoro
|
||||
if ( m_suData.find( sToolName) == m_suData.end()){
|
||||
@@ -889,7 +898,7 @@ ToolsMgr::ExportOneTool( const string& sToolName, Writer& TheWriter, const int&
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ToolsMgr::ToBeImported( const string& sFile, STRVECTOR& vsToolsNames, INTVECTOR& vToolsTypes)
|
||||
ToolsMgr::ToBeImported( const string& sFile, STRVECTOR& vsToolsNames, INTVECTOR& vToolsTypes) const
|
||||
{
|
||||
Scanner TheScanner ;
|
||||
if ( ! TheScanner.Init( sFile, ";")) {
|
||||
@@ -902,7 +911,7 @@ ToolsMgr::ToBeImported( const string& sFile, STRVECTOR& vsToolsNames, INTVECTOR&
|
||||
int nToolSize = 0 ;
|
||||
int nTotal = 0 ;
|
||||
bool bEnd = false ;
|
||||
if ( ! LoadHeader( TheScanner, nVersion, nToolSize, nTotal, bEnd)){
|
||||
if ( ! LoadHeader( TheScanner, nVersion, nToolSize, nTotal, bEnd)) {
|
||||
LOG_ERROR( GetEMkLogger(), "Tools ToBeImported : Error on Header") ;
|
||||
}
|
||||
|
||||
@@ -951,7 +960,7 @@ ToolsMgr::ToBeImported( const string& sFile, STRVECTOR& vsToolsNames, INTVECTOR&
|
||||
}
|
||||
|
||||
// aggiungo ultimo tool se ok
|
||||
if ( bAdd && bToolType && bToolName) {
|
||||
if ( bAdd && bToolType && bToolName) {
|
||||
vsToolsNames.push_back( sName) ;
|
||||
vToolsTypes.push_back( stoi( sType)) ;
|
||||
}
|
||||
@@ -977,14 +986,14 @@ ToolsMgr::Import( const string& sFile, const STRVECTOR& vsToolsToImport, const S
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
// Verfico che il nome non sia ripetuto nella lista dei vsToolsNames
|
||||
// Verifico che il nome non sia ripetuto nella lista dei vsToolsNames
|
||||
if ( i != vsToolsNames.size() - 1 && find( vsToolsNames.begin() + i + 1, vsToolsNames.end(), vsToolsNames[i]) != vsToolsNames.end()) {
|
||||
LOG_ERROR( GetEMkLogger(), ( " Error : name \"" + vsToolsNames[i] + "\" is already used").c_str()) ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
// sFile directory
|
||||
// File directory
|
||||
size_t pos = sFile.rfind( "\\") ;
|
||||
if ( pos == string::npos)
|
||||
return false ;
|
||||
@@ -1009,7 +1018,7 @@ ToolsMgr::Import( const string& sFile, const STRVECTOR& vsToolsToImport, const S
|
||||
|
||||
// leggo i tool
|
||||
string sLine ;
|
||||
if( ! TheScanner.GetLine( sLine))
|
||||
if ( ! TheScanner.GetLine( sLine))
|
||||
return false ;
|
||||
if ( sLine.front() != '[' || sLine.back() != ']')
|
||||
return false ;
|
||||
@@ -1023,7 +1032,7 @@ ToolsMgr::Import( const string& sFile, const STRVECTOR& vsToolsToImport, const S
|
||||
vector<string>::const_iterator it = find( vsToolsToImport.begin(), vsToolsToImport.end(), tData.m_sName) ;
|
||||
|
||||
// Se il tool non deve essere importato proseguo con il successivo
|
||||
if ( it == vsToolsToImport.end())
|
||||
if ( it == vsToolsToImport.end())
|
||||
continue ;
|
||||
|
||||
// Se errore nel leggere il tool, proseguo con il successivo
|
||||
@@ -1076,7 +1085,7 @@ ToolsMgr::Import( const string& sFile, const STRVECTOR& vsToolsToImport, const S
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
bool
|
||||
ToolsMgr::ReadTool( Scanner& TheScanner, ToolData& tData, const int& nToolSize) const
|
||||
ToolsMgr::ReadTool( Scanner& TheScanner, ToolData& tData, int nToolSize) const
|
||||
{
|
||||
string sLine ;
|
||||
TheScanner.GetLine( sLine) ;
|
||||
@@ -1113,49 +1122,56 @@ ToolsMgr::ReadTool( Scanner& TheScanner, ToolData& tData, const int& nToolSize)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
ToolsMgr::CopyToolDraw( const string& sDraw, const string& sOutDraw, const string& sToolName)
|
||||
ToolsMgr::CopyToolDraw( const string& sDraw, const string& sOutDraw, const string& sToolName) const
|
||||
{
|
||||
// se il file del disegno esiste lo copio nella nuova cartella
|
||||
if ( ExistsFile( sDraw)){
|
||||
if ( ExistsFile( sDraw)) {
|
||||
if ( ! CopyFileEgt( sDraw, sOutDraw)) {
|
||||
string sOut = " Error in copying " + sToolName + " draw" ;
|
||||
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// se il file non esiste e non è standard restituisco errore
|
||||
if ( ! IsUUID( GetFileTitleEgt( sDraw))) {
|
||||
string sOut = " Error : " + sToolName + " draw not found" ;
|
||||
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
|
||||
return false ;
|
||||
}
|
||||
// se il file non esiste ma è standard lo ricreo
|
||||
else {
|
||||
int nGenCtx = ExeGetCurrentContext() ;
|
||||
int nToolCtx = ExeInitContext() ;
|
||||
|
||||
bool bOk = SetCurrTool( sToolName) ; // setto il tool corrente per farne il disegno
|
||||
if ( ! bOk){
|
||||
string sOut = " Error in " + sToolName + " draw" ;
|
||||
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
if ( ExeTdbCurrToolDraw( nGenCtx, nToolCtx)) {
|
||||
string sOut = " Error : " + sToolName + " CurrToolDraw" ;
|
||||
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
|
||||
return false ;
|
||||
}
|
||||
if ( ! ExeSaveFile( sOutDraw, GDB_SV_CMPTXT)) {
|
||||
string sOut = " Error : saving " + sToolName + " tool draw" ;
|
||||
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
|
||||
return false ;
|
||||
}
|
||||
ExeSetCurrentContext( nGenCtx) ;
|
||||
ExeDeleteContext( nToolCtx) ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
return true ;
|
||||
|
||||
// se il file non esiste e non è standard restituisco errore
|
||||
if ( ! IsUUID( GetFileTitleEgt( sDraw))) {
|
||||
string sOut = " Error : " + sToolName + " draw not found" ;
|
||||
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// altrimenti il file non esiste ma è standard lo ricreo
|
||||
// recupero indice contesto corrente e creo nuovo contesto per disegno utensile
|
||||
int nGenCtx = ExeGetCurrentContext() ;
|
||||
int nToolCtx = ExeInitContext() ;
|
||||
// salvo dati utensile corrente
|
||||
bool bCurrToolOld = m_bCurrTool ;
|
||||
ToolData tdCurrToolOld = m_tdCurrTool ;
|
||||
// imposto utensile da esportare come corrente
|
||||
bool bOk = true ;
|
||||
if ( bOk && ! const_cast<ToolsMgr*>(this)->SetCurrTool( sToolName)) {
|
||||
string sOut = " Error in " + sToolName + " draw" ;
|
||||
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
|
||||
bOk = false ;
|
||||
}
|
||||
if ( bOk && ! ExeTdbCurrToolDraw( nGenCtx, nToolCtx)) {
|
||||
string sOut = " Error : " + sToolName + " CurrToolDraw" ;
|
||||
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
|
||||
bOk = false ;
|
||||
}
|
||||
if ( bOk && ! ExeSaveFile( sOutDraw, GDB_SV_CMPTXT)) {
|
||||
string sOut = " Error : saving " + sToolName + " tool draw" ;
|
||||
LOG_ERROR( GetEMkLogger(), sOut.c_str()) ;
|
||||
bOk = false ;
|
||||
}
|
||||
// ripristino utensile corrente
|
||||
const_cast<ToolsMgr*>(this)->m_bCurrTool = bCurrToolOld ;
|
||||
const_cast<ToolsMgr*>(this)->m_tdCurrTool = tdCurrToolOld ;
|
||||
// ripristino contesto corrente e cancello quello creato ad hoc
|
||||
ExeSetCurrentContext( nGenCtx) ;
|
||||
ExeDeleteContext( nToolCtx) ;
|
||||
|
||||
return bOk ;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user