EgtMachKernel 1.6k5 :

- aggiunta gestione DB lavorazioni.
This commit is contained in:
Dario Sassi
2015-11-14 16:24:20 +00:00
parent 2a7370bde8
commit 7640eab85e
23 changed files with 1652 additions and 153 deletions
+1 -1
View File
@@ -243,7 +243,7 @@ Drilling::SetParam( int nType, const string& sVal)
switch ( nType) {
case MPA_TOOL : {
const ToolData* pTdata ;
if ( ! m_Params.VerifyTool( m_pMchMgr, sVal, pTdata))
if ( ! m_Params.VerifyTool( m_pMchMgr->GetCurrToolsMgr(), sVal, pTdata))
return false ;
m_Params.m_sToolName = sVal ;
m_Params.m_ToolUuid = pTdata->m_Uuid ;
+203 -8
View File
@@ -51,7 +51,74 @@ static const std::array<std::string,KEY_ZZZ> sDrillingKey = {
"UUID"} ;
//----------------------------------------------------------------------------
MCHDATA_REGISTER( "DRILLING", DrillingData) ;
MCHDATA_REGISTER( MT_DRILLING, "DRILLING", DrillingData) ;
//----------------------------------------------------------------------------
DrillingData*
DrillingData::Clone( void) const
{
// alloco oggetto
DrillingData* pDdata = new(nothrow) DrillingData ;
// copio i dati
if ( pDdata != nullptr) {
if ( ! pDdata->CopyFrom( this)) {
delete pDdata ;
return nullptr ;
}
}
return pDdata ;
}
//----------------------------------------------------------------------------
bool
DrillingData::CopyFrom( const MachiningData* pMdata)
{
// è inutile copiare se sorgente coincide con destinazione
if ( pMdata == this)
return true ;
// la sorgente deve essere dello stesso tipo
const DrillingData* pDdata = dynamic_cast<const DrillingData*>( pMdata) ;
if ( pDdata == nullptr)
return false ;
// eseguo copia
m_Uuid = pDdata->m_Uuid ;
m_sName = pDdata->m_sName ;
m_ToolUuid = pDdata->m_ToolUuid ;
m_sToolName = pDdata->m_sToolName ;
m_bInvert = pDdata->m_bInvert ;
m_dStartPos = pDdata->m_dStartPos ;
m_dStartSlowLen = pDdata->m_dStartSlowLen ;
m_dEndSlowLen = pDdata->m_dEndSlowLen ;
m_dThroughAddLen = pDdata->m_dThroughAddLen ;
m_dStep = pDdata->m_dStep ;
m_dReturnPos = pDdata->m_dReturnPos ;
return true ;
}
//----------------------------------------------------------------------------
bool
DrillingData::SameAs(const MachiningData* pMdata) const
{
// se coincide con altro -> uguali
if ( pMdata == this)
return true ;
// se sono di tipo diverso -> diversi
const DrillingData* pDdata = dynamic_cast<const DrillingData*>( pMdata) ;
if ( pDdata == nullptr)
return false ;
// confronto termine a termine
return ( m_Uuid == pDdata->m_Uuid &&
m_sName == pDdata->m_sName &&
m_ToolUuid == pDdata->m_ToolUuid &&
m_sToolName == pDdata->m_sToolName &&
m_bInvert == pDdata->m_bInvert &&
m_dStartPos == pDdata->m_dStartPos &&
m_dStartSlowLen == pDdata->m_dStartSlowLen &&
m_dEndSlowLen == pDdata->m_dEndSlowLen &&
m_dThroughAddLen == pDdata->m_dThroughAddLen &&
m_dStep == pDdata->m_dStep &&
m_dReturnPos == pDdata->m_dReturnPos) ;
}
//----------------------------------------------------------------------------
int
@@ -116,7 +183,6 @@ DrillingData::FromString( const string& sString, int& nKey)
break ;
case KEY_TNAME :
m_sToolName = sVal ;
bOk = ! m_sToolName.empty() ;
break ;
case KEY_TUUID :
bOk = ::FromString( sVal, m_ToolUuid) ;
@@ -153,14 +219,11 @@ DrillingData::ToString( int nInd) const
//----------------------------------------------------------------------------
bool
DrillingData::VerifyTool( MachMgr* pMachMgr, const std::string& sVal, const ToolData*& pTdata) const
DrillingData::VerifyTool( const ToolsMgr* pToolsMgr, const std::string& sVal, const ToolData*& pTdata) const
{
if ( pMachMgr == nullptr)
if ( pToolsMgr == nullptr)
return false ;
ToolsMgr* pTMgr = pMachMgr->GetCurrToolsMgr() ;
if ( pTMgr == nullptr)
return false ;
pTdata = pTMgr->GetTool( sVal) ;
pTdata = pToolsMgr->GetTool( sVal) ;
if ( pTdata == nullptr)
return false ;
if ( ( pTdata->m_nType & TF_DRILLBIT) == 0 ||
@@ -168,3 +231,135 @@ DrillingData::VerifyTool( MachMgr* pMachMgr, const std::string& sVal, const Tool
return false ;
return true ;
}
//----------------------------------------------------------------------------
bool
DrillingData::SetParam( int nType, bool bVal)
{
switch ( nType) {
case MPA_INVERT :
m_bInvert = bVal ;
return true ;
}
return false ;
}
//----------------------------------------------------------------------------
bool
DrillingData::SetParam( int nType, int nVal)
{
return false ;
}
//----------------------------------------------------------------------------
bool
DrillingData::SetParam( int nType, double dVal)
{
switch ( nType) {
case MPA_STARTPOS :
m_dStartPos = dVal ;
return true ;
case MPA_STARTSLOWLEN :
m_dStartSlowLen = dVal ;
return true ;
case MPA_ENDSLOWLEN :
m_dEndSlowLen = dVal ;
return true ;
case MPA_THROUADDLEN :
m_dThroughAddLen = dVal ;
return true ;
case MPA_STEP :
m_dStep = dVal ;
return true ;
case MPA_RETURNPOS :
m_dReturnPos = dVal ;
return true ;
}
return false ;
}
//----------------------------------------------------------------------------
bool
DrillingData::SetParam( int nType, const string& sVal)
{
switch ( nType) {
case MPA_NAME :
m_sName = sVal ;
return true ;
case MPA_TOOL :
m_sToolName = sVal ;
return true ;
case MPA_TUUID :
return ::FromString( sVal, m_ToolUuid) ;
case MPA_UUID :
return ::FromString( sVal, m_Uuid) ;
}
return false ;
}
//----------------------------------------------------------------------------
bool
DrillingData::GetParam( int nType, bool& bVal) const
{
switch ( nType) {
case MPA_INVERT :
bVal = m_bInvert ;
return true ;
}
return false ;
}
//----------------------------------------------------------------------------
bool
DrillingData::GetParam( int nType, int& nVal) const
{
return false ;
}
//----------------------------------------------------------------------------
bool
DrillingData::GetParam( int nType, double& dVal) const
{
switch ( nType) {
case MPA_STARTPOS :
dVal = m_dStartPos ;
return true ;
case MPA_STARTSLOWLEN :
dVal = m_dStartSlowLen ;
return true ;
case MPA_ENDSLOWLEN :
dVal = m_dEndSlowLen ;
return true ;
case MPA_THROUADDLEN :
dVal = m_dThroughAddLen ;
return true ;
case MPA_STEP :
dVal = m_dStep ;
return true ;
case MPA_RETURNPOS :
dVal = m_dReturnPos ;
return true ;
}
return false ;
}
//----------------------------------------------------------------------------
bool
DrillingData::GetParam( int nType, string& sVal) const
{
switch ( nType) {
case MPA_NAME :
sVal = m_sName ;
return true ;
case MPA_TOOL :
sVal = m_sToolName ;
return true ;
case MPA_TUUID :
sVal = ::ToString( m_ToolUuid) ;
return true ;
case MPA_UUID :
sVal = ::ToString( m_Uuid) ;
return true ;
}
return false ;
}
+12 -4
View File
@@ -14,7 +14,6 @@
#pragma once
#include "MachiningData.h"
#include "MachMgr.h"
//----------------------------------------------------------------------------
struct DrillingData : public MachiningData
@@ -32,14 +31,23 @@ struct DrillingData : public MachiningData
DrillingData( void)
: m_ToolUuid(), m_bInvert( false), m_dStartPos( 0), m_dStartSlowLen( 0), m_dEndSlowLen( 0),
m_dThroughAddLen( 0), m_dStep( 0), m_dReturnPos( 0) {}
virtual DrillingData* Clone( void) const ;
virtual bool CopyFrom( const MachiningData* pMdata) ;
virtual bool SameAs(const MachiningData* pMdata) const ;
virtual int GetType( void) const { return MT_DRILLING ; }
virtual int GetSize( void) const ;
virtual std::string GetTitle( void) const ;
virtual bool FromString( const std::string& sString, int& nKey) ;
virtual std::string ToString( int nInd) const ;
bool VerifyTool( MachMgr* pMachMgr, const std::string& sVal, const ToolData*& pTdata) const ;
virtual bool SetParam( int nType, bool bVal) ;
virtual bool SetParam( int nType, int nVal) ;
virtual bool SetParam( int nType, double dVal) ;
virtual bool SetParam( int nType, const std::string& sVal) ;
virtual bool GetParam( int nType, bool& bVal) const ;
virtual bool GetParam( int nType, int& nVal) const ;
virtual bool GetParam( int nType, double& dVal) const ;
virtual bool GetParam( int nType, std::string& sVal) const ;
virtual bool VerifyTool( const ToolsMgr* pToolsMgr, const std::string& sVal, const ToolData*& pTdata) const ;
} ;
//----------------------------------------------------------------------------
BIN
View File
Binary file not shown.
+2 -1
View File
@@ -231,6 +231,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClCompile Include="Machining.cpp" />
<ClCompile Include="MachiningsMgr.cpp" />
<ClCompile Include="MachMgrBasic.cpp" />
<ClCompile Include="MachMgrDBMachinings.cpp" />
<ClCompile Include="MachMgrFixtures.cpp" />
<ClCompile Include="MachMgrGeneration.cpp" />
<ClCompile Include="MachMgrMachGroups.cpp" />
@@ -239,7 +240,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
<ClCompile Include="MachMgrParts.cpp" />
<ClCompile Include="MachMgrRawParts.cpp" />
<ClCompile Include="MachMgrSimulation.cpp" />
<ClCompile Include="MachMgrTools.cpp" />
<ClCompile Include="MachMgrDBTools.cpp" />
<ClCompile Include="Milling.cpp" />
<ClCompile Include="MillingData.cpp" />
<ClCompile Include="Sawing.cpp" />
+6 -3
View File
@@ -135,9 +135,6 @@
<ClCompile Include="CamData.cpp">
<Filter>Source Files\Operations</Filter>
</ClCompile>
<ClCompile Include="MachMgrTools.cpp">
<Filter>Source Files\MachMgr</Filter>
</ClCompile>
<ClCompile Include="Simulator.cpp">
<Filter>Source Files\Simulation</Filter>
</ClCompile>
@@ -153,6 +150,12 @@
<ClCompile Include="MachineWriter.cpp">
<Filter>Source Files\Machine</Filter>
</ClCompile>
<ClCompile Include="MachMgrDBMachinings.cpp">
<Filter>Source Files\MachMgr</Filter>
</ClCompile>
<ClCompile Include="MachMgrDBTools.cpp">
<Filter>Source Files\MachMgr</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="DllMain.h">
+25 -5
View File
@@ -99,18 +99,20 @@ class MachMgr : public IMachMgr
virtual int AddFixture( const std::string& sName, const Point3d& ptPos, double dAngRotDeg) ;
virtual bool ShowOnlyTable( bool bVal) ;
// Tools DataBase
virtual bool TdbGetToolNewName( std::string& sName) ;
virtual bool TdbGetToolNewName( std::string& sName) const ;
virtual bool TdbAddTool( const std::string& sName, int nType) ;
virtual bool TdbCopyTool( const std::string& sSource, const std::string& sName) ;
virtual bool TdbRemoveTool( const std::string& sName) ;
virtual bool TdbGetFirstTool( int nFamily, std::string& sName, int& nType) ;
virtual bool TdbGetNextTool( int nFamily, std::string& sName, int& nType) ;
virtual bool TdbGetFirstTool( int nFamily, std::string& sName, int& nType) const ;
virtual bool TdbGetNextTool( int nFamily, std::string& sName, int& nType) const ;
virtual bool TdbSetCurrTool( const std::string& sName) ;
virtual bool TdbSaveCurrTool( void) ;
virtual bool TdbIsCurrToolModified( void) ;
virtual bool TdbIsCurrToolModified( void) const ;
virtual bool TdbSetCurrToolParam( int nType, bool bVal) ;
virtual bool TdbSetCurrToolParam( int nType, int nVal) ;
virtual bool TdbSetCurrToolParam( int nType, double dVal) ;
virtual bool TdbSetCurrToolParam( int nType, const std::string& sVal) ;
virtual bool TdbGetCurrToolParam( int nType, bool& bVal) const ;
virtual bool TdbGetCurrToolParam( int nType, int& nVal) const ;
virtual bool TdbGetCurrToolParam( int nType, double& dVal) const ;
virtual bool TdbGetCurrToolParam( int nType, std::string& sVal) const ;
@@ -118,7 +120,25 @@ class MachMgr : public IMachMgr
virtual bool TdbGetToolDir( std::string& sToolDir) const ;
virtual bool TdbGetToolHolderDir( std::string& sTHolderDir) const ;
// Machinings DataBase
// ...
virtual bool MdbGetMachiningNewName( std::string& sName) const ;
virtual bool MdbAddMachining( const std::string& sName, int nType) ;
virtual bool MdbCopyMachining( const std::string& sSource, const std::string& sName) ;
virtual bool MdbRemoveMachining( const std::string& sName) ;
virtual bool MdbGetFirstMachining( int nType, std::string& sName) const ;
virtual bool MdbGetNextMachining( int nType, std::string& sName) const ;
virtual bool MdbSetCurrMachining( const std::string& sName) ;
virtual bool MdbSaveCurrMachining( void) ;
virtual bool MdbIsCurrMachiningModified( void) const ;
virtual bool MdbSetCurrMachiningParam( int nType, bool bVal) ;
virtual bool MdbSetCurrMachiningParam( int nType, int nVal) ;
virtual bool MdbSetCurrMachiningParam( int nType, double dVal) ;
virtual bool MdbSetCurrMachiningParam( int nType, const std::string& sVal) ;
virtual bool MdbGetCurrMachiningParam( int nType, bool& bVal) const ;
virtual bool MdbGetCurrMachiningParam( int nType, int& nVal) const ;
virtual bool MdbGetCurrMachiningParam( int nType, double& dVal) const ;
virtual bool MdbGetCurrMachiningParam( int nType, std::string& sVal) const ;
virtual bool MdbSave( void) const ;
virtual bool MdbGetMachiningDir( std::string& sMchDir) const ;
// Operations : general
virtual int GetOperationCount( void) const ;
virtual int GetFirstOperation( void) const ;
+245
View File
@@ -0,0 +1,245 @@
//----------------------------------------------------------------------------
// EgalTech 2015-2015
//----------------------------------------------------------------------------
// File : MachMgrDBMachinings.cpp Data : 11.11.15 Versione : 1.6k5
// Contenuto : Implementazione gestione DB lavorazioni della classe MachMgr.
//
//
//
// Modifiche : 11.11.15 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
//--------------------------- Include ----------------------------------------
#include "stdafx.h"
#include "DllMain.h"
#include "MachMgr.h"
using namespace std ;
//----------------------------------------------------------------------------
bool
MachMgr::MdbGetMachiningNewName( string& sName) const
{
// recupero il gestore di lavorazioni della macchina corrente
MachiningsMgr* pMsMgr = GetCurrMachiningsMgr() ;
if ( pMsMgr == nullptr)
return false ;
// verifico nome ed eventualmente lo modifico per renderlo nuovo
return pMsMgr->GetMachiningNewName( sName) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::MdbAddMachining( const string& sName, int nType)
{
// recupero il gestore di lavorazioni della macchina corrente
MachiningsMgr* pMsMgr = GetCurrMachiningsMgr() ;
if ( pMsMgr == nullptr)
return false ;
// aggiungo la lavorazione al DB lavorazioni
return pMsMgr->AddMachining( sName, nType) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::MdbCopyMachining( const string& sSource, const string& sName)
{
// recupero il gestore di lavorazioni della macchina corrente
MachiningsMgr* pMsMgr = GetCurrMachiningsMgr() ;
if ( pMsMgr == nullptr)
return false ;
// copio la lavorazione nel DB lavorazioni
return pMsMgr->CopyMachining( sSource, sName) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::MdbRemoveMachining( const string& sName)
{
// recupero il gestore di lavorazioni della macchina corrente
MachiningsMgr* pMsMgr = GetCurrMachiningsMgr() ;
if ( pMsMgr == nullptr)
return false ;
// rimuovo la lavorazione dal DB lavorazioni
return pMsMgr->RemoveMachining( sName) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::MdbGetFirstMachining( int nType, string& sName) const
{
// recupero il gestore di lavorazioni della macchina corrente
MachiningsMgr* pMsMgr = GetCurrMachiningsMgr() ;
if ( pMsMgr == nullptr)
return false ;
// cerco la prima lavorazione del tipo richiesto nel DB lavorazioni
return pMsMgr->GetFirstMachining( nType, sName) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::MdbGetNextMachining( int nType, string& sName) const
{
// recupero il gestore di lavorazioni della macchina corrente
MachiningsMgr* pMsMgr = GetCurrMachiningsMgr() ;
if ( pMsMgr == nullptr)
return false ;
// cerco la successiva lavorazione del tipo richiesto nel DB lavorazioni
return pMsMgr->GetNextMachining( nType, sName) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::MdbSetCurrMachining( const string& sName)
{
// recupero il gestore di lavorazioni della macchina corrente
MachiningsMgr* pMsMgr = GetCurrMachiningsMgr() ;
if ( pMsMgr == nullptr)
return false ;
// imposto la lavorazione corrente
return pMsMgr->SetCurrMachining( sName) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::MdbSaveCurrMachining( void)
{
// recupero il gestore di lavorazioni della macchina corrente
MachiningsMgr* pMsMgr = GetCurrMachiningsMgr() ;
if ( pMsMgr == nullptr)
return false ;
// salvo la lavorazione corrente
return pMsMgr->SaveCurrMachining() ;
}
//----------------------------------------------------------------------------
bool
MachMgr::MdbIsCurrMachiningModified( void) const
{
// recupero il gestore di lavorazioni della macchina corrente
MachiningsMgr* pMsMgr = GetCurrMachiningsMgr() ;
if ( pMsMgr == nullptr)
return false ;
// verifico se la lavorazione corrente è stata modificata
return pMsMgr->IsCurrMachiningModified() ;
}
//----------------------------------------------------------------------------
bool
MachMgr::MdbSetCurrMachiningParam( int nType, bool bVal)
{
// recupero il gestore di lavorazioni della macchina corrente
MachiningsMgr* pMsMgr = GetCurrMachiningsMgr() ;
if ( pMsMgr == nullptr)
return false ;
// assegno il parametro
return pMsMgr->SetCurrMachiningParam( nType, bVal) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::MdbSetCurrMachiningParam( int nType, int nVal)
{
// recupero il gestore di lavorazioni della macchina corrente
MachiningsMgr* pMsMgr = GetCurrMachiningsMgr() ;
if ( pMsMgr == nullptr)
return false ;
// assegno il parametro
return pMsMgr->SetCurrMachiningParam( nType, nVal) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::MdbSetCurrMachiningParam( int nType, double dVal)
{
// recupero il gestore di lavorazioni della macchina corrente
MachiningsMgr* pMsMgr = GetCurrMachiningsMgr() ;
if ( pMsMgr == nullptr)
return false ;
// assegno il parametro
return pMsMgr->SetCurrMachiningParam( nType, dVal) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::MdbSetCurrMachiningParam( int nType, const string& sVal)
{
// recupero il gestore di lavorazioni della macchina corrente
MachiningsMgr* pMsMgr = GetCurrMachiningsMgr() ;
if ( pMsMgr == nullptr)
return false ;
// assegno il parametro
return pMsMgr->SetCurrMachiningParam( nType, sVal) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::MdbGetCurrMachiningParam( int nType, bool& bVal) const
{
// recupero il gestore di lavorazioni della macchina corrente
MachiningsMgr* pMsMgr = GetCurrMachiningsMgr() ;
if ( pMsMgr == nullptr)
return false ;
// recupero il parametro
return pMsMgr->GetCurrMachiningParam( nType, bVal) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::MdbGetCurrMachiningParam( int nType, int& nVal) const
{
// recupero il gestore di lavorazioni della macchina corrente
MachiningsMgr* pMsMgr = GetCurrMachiningsMgr() ;
if ( pMsMgr == nullptr)
return false ;
// recupero il parametro
return pMsMgr->GetCurrMachiningParam( nType, nVal) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::MdbGetCurrMachiningParam( int nType, double& dVal) const
{
// recupero il gestore di lavorazioni della macchina corrente
MachiningsMgr* pMsMgr = GetCurrMachiningsMgr() ;
if ( pMsMgr == nullptr)
return false ;
// recupero il parametro
return pMsMgr->GetCurrMachiningParam( nType, dVal) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::MdbGetCurrMachiningParam( int nType, string& sVal) const
{
// recupero il gestore di lavorazioni della macchina corrente
MachiningsMgr* pMsMgr = GetCurrMachiningsMgr() ;
if ( pMsMgr == nullptr)
return false ;
// recupero il parametro
return pMsMgr->GetCurrMachiningParam( nType, sVal) ;
}
//----------------------------------------------------------------------------
bool
MachMgr::MdbSave( void) const
{
// recupero il gestore di lavorazioni della macchina corrente
MachiningsMgr* pMsMgr = GetCurrMachiningsMgr() ;
if ( pMsMgr == nullptr)
return false ;
// salvo il DB lavorazioni
return pMsMgr->Save() ;
}
//----------------------------------------------------------------------------
bool
MachMgr::MdbGetMachiningDir( string& sMchDir) const
{
if ( GetCurrMachine() == nullptr)
return false ;
sMchDir = m_sMachinesDir + "\\" + GetCurrMachine()->GetMachineName() + "\\" + MACHININGS_DIR ;
return true ;
}
+30 -6
View File
@@ -1,8 +1,8 @@
//----------------------------------------------------------------------------
// EgalTech 2015-2015
//----------------------------------------------------------------------------
// File : MachMgrTools.cpp Data : 17.09.15 Versione : 1.6i7
// Contenuto : Implementazione gestione utensili della classe MachMgr.
// File : MachMgrDBTools.cpp Data : 17.09.15 Versione : 1.6i7
// Contenuto : Implementazione gestione DB utensili della classe MachMgr.
//
//
//
@@ -20,7 +20,7 @@ using namespace std ;
//----------------------------------------------------------------------------
bool
MachMgr::TdbGetToolNewName( string& sName)
MachMgr::TdbGetToolNewName( string& sName) const
{
// recupero il gestore di utensili della macchina corrente
ToolsMgr* pTsMgr = GetCurrToolsMgr() ;
@@ -68,7 +68,7 @@ MachMgr::TdbRemoveTool( const string& sName)
//----------------------------------------------------------------------------
bool
MachMgr::TdbGetFirstTool( int nFamily, string& sName, int& nType)
MachMgr::TdbGetFirstTool( int nFamily, string& sName, int& nType) const
{
// recupero il gestore di utensili della macchina corrente
ToolsMgr* pTsMgr = GetCurrToolsMgr() ;
@@ -80,7 +80,7 @@ MachMgr::TdbGetFirstTool( int nFamily, string& sName, int& nType)
//----------------------------------------------------------------------------
bool
MachMgr::TdbGetNextTool( int nFamily, string& sName, int& nType)
MachMgr::TdbGetNextTool( int nFamily, string& sName, int& nType) const
{
// recupero il gestore di utensili della macchina corrente
ToolsMgr* pTsMgr = GetCurrToolsMgr() ;
@@ -116,7 +116,7 @@ MachMgr::TdbSaveCurrTool( void)
//----------------------------------------------------------------------------
bool
MachMgr::TdbIsCurrToolModified( void)
MachMgr::TdbIsCurrToolModified( void) const
{
// recupero il gestore di utensili della macchina corrente
ToolsMgr* pTsMgr = GetCurrToolsMgr() ;
@@ -126,6 +126,18 @@ MachMgr::TdbIsCurrToolModified( void)
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)
@@ -162,6 +174,18 @@ MachMgr::TdbSetCurrToolParam( int nType, const string& sVal)
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
+1 -1
View File
@@ -50,7 +50,7 @@ MachMgr::LoadMachine( const string& sMachineName)
// creo e carico il DB lavorazioni
PtrOwner<MachiningsMgr> pMsMgr( new( nothrow) MachiningsMgr) ;
string sMachsFile = m_sMachinesDir + "\\" + sMachineName + "\\" + MACHININGS_DIR + "\\" + MACHININGS_FILE ;
if ( IsNull( pMsMgr) || ! pMsMgr->Init( sMachsFile) || ! pMsMgr->Load())
if ( IsNull( pMsMgr) || ! pMsMgr->Load( sMachsFile, Get( pTsMgr)))
return false ;
// salvo nel vettore
m_vMachines.emplace_back( Release( pMch), Release( pTsMgr), Release( pMsMgr)) ;
+23 -9
View File
@@ -14,6 +14,8 @@
#pragma once
#include "ToolsMgr.h"
#include "/EgtDEv/Include/EmkMachiningConst.h"
#include "/EgtDev/Include/EGnEgtUUID.h"
#include "/EgtDev/Include/EgtStringBase.h"
#include <string>
@@ -26,20 +28,32 @@ struct MachiningData
MachiningData( void)
: m_Uuid() {}
virtual ~MachiningData( void) {}
virtual MachiningData* Clone( void) const = 0 ;
virtual bool CopyFrom( const MachiningData* pMdata) = 0 ;
virtual bool SameAs( const MachiningData* pMdata) const = 0 ;
virtual int GetType( void) const = 0 ;
virtual int GetSize( void) const = 0 ;
virtual std::string GetTitle( void) const = 0 ;
virtual bool FromString( const std::string& sString, int& nKey) = 0 ;
virtual std::string ToString( int nInd) const = 0 ;
virtual bool SetParam( int nType, bool bVal) = 0 ;
virtual bool SetParam( int nType, int nVal) = 0 ;
virtual bool SetParam( int nType, double dVal) = 0 ;
virtual bool SetParam( int nType, const std::string& sVal) = 0 ;
virtual bool GetParam( int nType, bool& bVal) const = 0 ;
virtual bool GetParam( int nType, int& nVal) const = 0 ;
virtual bool GetParam( int nType, double& dVal) const = 0 ;
virtual bool GetParam( int nType, std::string& sVal) const = 0 ;
virtual bool VerifyTool( const ToolsMgr* pToolsMgr, const std::string& sVal, const ToolData*& pTdata) const = 0 ;
} ;
//----------------------------------------------------------------------------
// Tipologia di lavorazioni
enum MachiningType {
MT_NONE = 0,
MT_DRILLING = 1,
MT_SAWING = 2,
MT_MILLING = 3,
MT_POCKETING = 4,
MT_MORTISING = 5
} ;
inline bool
SameMachining( const MachiningData* pM1, const MachiningData* pM2)
{
// se di tipo diverso, ovviamente sono diversi
if ( pM1->GetType() != pM2->GetType())
return false ;
// eseguo confronto
return pM1->SameAs( pM2) ;
}
+35 -14
View File
@@ -18,30 +18,38 @@
#include <unordered_map>
//----------------------------------------------------------------------------
#define MCHDATA_REGISTER( sName, T) static const bool bReg_##T = \
MachiningDataRegister<T>::DoRegister( sName)
#define MCHDATA_GETNAME( T) MachiningDataRegister<T>::GetName()
#define MCHDATA_CREATE( sName) MachiningDataFactory::Create( sName)
#define MCHDATA_GETLIST( vsList) MachiningDataFactory::GetList( vsList)
#define MCHDATA_REGISTER( nType, sName, T) static const bool bReg_##T = \
MachiningDataRegister<T>::DoRegister( nType, sName)
#define MCHDATA_GETTYPE( T) MachiningDataRegister<T>::GetType()
#define MCHDATA_GETNAME( T) MachiningDataRegister<T>::GetName()
#define MCHDATA_NAMETOTYPE( sName) MachiningDataFactory::NameToType( sName)
#define MCHDATA_CREATE( nType) MachiningDataFactory::Create( nType)
#define MCHDATA_GETLIST( vsList) MachiningDataFactory::GetList( vsList)
//----------------------------------------------------------------------------
template <typename T>
class MachiningDataRegister
{
public :
static bool DoRegister( const std::string& sName)
{ if ( ! MachiningDataFactory::Register( sName, Create))
static bool DoRegister( int nType, const std::string& sName)
{ if ( ! MachiningDataFactory::Register( nType, sName, Create))
return false ;
GetTypePrivate() = nType ;
GetNamePrivate() = sName ;
return true ; }
static MachiningData* Create( void)
{ return new(nothrow) T ; }
static int GetType( void)
{ return GetTypePrivate() ; }
static const std::string& GetName( void)
{ return GetNamePrivate() ; }
private :
MachiningDataRegister( void) {}
~MachiningDataRegister( void) {}
static int& GetTypePrivate( void)
{ static int s_nType ;
return s_nType ; }
static std::string& GetNamePrivate( void)
{ static std::string s_sName ;
return s_sName ; }
@@ -54,11 +62,18 @@ class MachiningDataFactory
// definizione del tipo funzione di creazione
typedef MachiningData* ( *MachiningDataCreator) ( void) ;
// per registrare le funzioni di creazione
static bool Register( const std::string& sName, MachiningDataCreator Creator)
{ return GetCreatorMap().emplace( sName, Creator).second ; }
static bool Register( int nType, const std::string& sName, MachiningDataCreator Creator)
{ return GetCreatorMap().emplace( nType, Creator).second &&
GetNameTypeMap().emplace( sName, nType).second ; }
// per restituire il tipo dato il nome
static int NameToType( const std::string& sName)
{ auto Iter = GetNameTypeMap().find( sName) ;
if ( Iter != GetNameTypeMap().end())
return Iter->second ;
return 0 ; }
// per creare l'oggetto richiesto
static MachiningData* Create( const std::string& sName)
{ auto Iter = GetCreatorMap().find( sName) ;
static MachiningData* Create( int nType)
{ auto Iter = GetCreatorMap().find( nType) ;
if ( Iter != GetCreatorMap().end()) {
if ( Iter->second != nullptr)
return Iter->second() ;
@@ -71,7 +86,7 @@ class MachiningDataFactory
if ( &vsList == nullptr)
return false ;
// ciclo sugli oggetti registrati
for ( auto Iter = GetCreatorMap().cbegin() ; Iter != GetCreatorMap().cend() ; ++ Iter)
for ( auto Iter = GetNameTypeMap().cbegin() ; Iter != GetNameTypeMap().cend() ; ++ Iter)
vsList.emplace_back( Iter->first) ;
return true ;
}
@@ -79,8 +94,14 @@ class MachiningDataFactory
private :
MachiningDataFactory( void) {}
~MachiningDataFactory( void) {}
// definizione del tipo mappa con coppie nome, funzione di creazione
typedef std::unordered_map<std::string, MachiningDataCreator> CreatorMap ;
// definizione del tipo mappa con coppie nome, tipo
typedef std::unordered_map<std::string, int> NameTypeMap ;
// metodo di accesso alla mappa statica
static NameTypeMap& GetNameTypeMap( void)
{ static NameTypeMap s_NameTypeMap ;
return s_NameTypeMap ; }
// definizione del tipo mappa con coppie tipo, funzione di creazione
typedef std::unordered_map<int, MachiningDataCreator> CreatorMap ;
// metodo di accesso alla mappa statica
static CreatorMap& GetCreatorMap( void)
{ static CreatorMap s_CreatorMap ;
+278 -17
View File
@@ -16,6 +16,7 @@
#include "MachiningsMgr.h"
#include "MachiningDataFactory.h"
#include "DllMain.h"
#include "/EgtDEv/Include/EmkMachiningConst.h"
#include "/EgtDEv/Include/EGnStringUtils.h"
#include "/EgtDEv/Include/EGnFileUtils.h"
#include "/EgtDEv/Include/EGnScanner.h"
@@ -34,38 +35,61 @@ const string MF_TOTAL = "TOTAL" ;
//----------------------------------------------------------------------------
MachiningsMgr::MachiningsMgr( void)
{
m_nCounter = 0 ;
m_pTsMgr = nullptr ;
m_suCIter = m_suData.cend() ;
m_pCurrMach = nullptr ;
m_bModified = false ;
}
//----------------------------------------------------------------------------
MachiningsMgr::~MachiningsMgr( void)
{
Clear() ;
}
//----------------------------------------------------------------------------
bool
MachiningsMgr::Clear( void)
{
// libero la memoria dalle lavorazioni
for ( auto iIter = m_umData.begin() ; iIter != m_umData.end() ; ++ iIter) {
if ( iIter->second != nullptr)
delete iIter->second ;
}
// reset puntatore a gestore utensili
m_pTsMgr = nullptr ;
// pulisco le tabelle
m_umData.clear() ;
m_suData.clear() ;
}
//----------------------------------------------------------------------------
bool
MachiningsMgr::Init( const string& sMachsFile)
{
// salvo la path del file con i dati
m_sMachsFile = sMachsFile ;
// log
string sOut = "MachiningsMgr Init : " + m_sMachsFile ;
LOG_INFO( GetEMkLogger(), sOut.c_str())
// reinizializzo stato
m_suCIter = m_suData.cend() ;
if ( m_pCurrMach != nullptr) {
delete m_pCurrMach ;
m_pCurrMach = nullptr ;
}
m_bModified = false ;
return true ;
}
//----------------------------------------------------------------------------
bool
MachiningsMgr::Load( void)
MachiningsMgr::Load( const string& sMachsFile, const ToolsMgr* pTsMgr)
{
// pulisco
Clear() ;
// salvo la path del file con i dati
m_sMachsFile = sMachsFile ;
{ string sOut = "MachiningsMgr Init : " + m_sMachsFile ;
LOG_INFO( GetEMkLogger(), sOut.c_str()) }
// verifico il gestore degli utensili
if ( pTsMgr == nullptr) {
LOG_ERROR( GetEMkLogger(), "LoadMachinings : Error on ToolsMgr")
return false ;
}
m_pTsMgr = pTsMgr ;
// inizializzo lo scanner
Scanner TheScanner ;
if ( ! TheScanner.Init( m_sMachsFile, ";")) {
@@ -161,7 +185,7 @@ MachiningsMgr::LoadOneMachining( Scanner& TheScanner, bool& bEnd)
SplitFirst( sLine, "_", sType, sCount) ;
ToUpper( sType) ;
// alloco la lavorazione del tipo corrispondente
PtrOwner<MachiningData> pMch( MCHDATA_CREATE( sType)) ;
PtrOwner<MachiningData> pMch( MCHDATA_CREATE( MCHDATA_NAMETOTYPE( sType))) ;
if ( IsNull( pMch))
return false ;
bool bOk = true ;
@@ -221,9 +245,10 @@ MachiningsMgr::Save( bool bCompressed) const
}
// ciclo su tutti i nomi delle lavorazioni
int nCounter = 0 ;
for ( auto iIter = m_suData.cbegin() ; iIter != m_suData.cend() ; ++ iIter) {
// salvo l'utensile
if ( ! SaveOneMachining( iIter->second, TheWriter)) {
if ( ! SaveOneMachining( iIter->second, nCounter, TheWriter)) {
string sOut = "SaveMachinings : Error on machining " + iIter->first ;
LOG_ERROR( GetEMkLogger(), sOut.c_str())
return false ;
@@ -258,7 +283,7 @@ MachiningsMgr::SaveHeader( Writer& TheWriter) const
//----------------------------------------------------------------------------
bool
MachiningsMgr::SaveOneMachining( const EgtUUID& Uuid, Writer& TheWriter) const
MachiningsMgr::SaveOneMachining( const EgtUUID& Uuid, int& nCounter, Writer& TheWriter) const
{
// recupero i dati della lavorazione
auto iIter = m_umData.find( Uuid) ;
@@ -266,7 +291,7 @@ MachiningsMgr::SaveOneMachining( const EgtUUID& Uuid, Writer& TheWriter) const
return false ;
const MachiningData* pmData = iIter->second ;
// scrivo i dati della lavorazione
string sOut = "[" + pmData->GetTitle() + "_" + ToString( ++ m_nCounter, 3) + "]" ;
string sOut = "[" + pmData->GetTitle() + "_" + ToString( ++ nCounter, 3) + "]" ;
bool bOk = TheWriter.OutText( sOut) ;
for ( int i = 0 ; i < pmData->GetSize() ; ++ i) {
string sOut = pmData->ToString( i) ;
@@ -275,6 +300,104 @@ MachiningsMgr::SaveOneMachining( const EgtUUID& Uuid, Writer& TheWriter) const
return bOk ;
}
//----------------------------------------------------------------------------
bool
MachiningsMgr::GetMachiningNewName( string& sName) const
{
// il parametro nome deve essere valido
if ( &sName == nullptr)
return false ;
// se nome vuoto, assegno radice standard
if ( sName.empty())
sName = "Mach" ;
// verifico che il nome sia unico
int nCount = 0 ;
string sOrigName = sName ;
while ( GetMachining( sName) != nullptr) {
++ nCount ;
sName = sOrigName + "_" + ToString( nCount) ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
MachiningsMgr::AddMachining( const string& sName, int nType)
{
// verifico unicità del nome
if ( m_suData.find( sName) != m_suData.end())
return false ;
// verifico validità del tipo
if ( ! IsValidMachiningType( nType))
return false ;
// alloco la lavorazione del tipo corrispondente
PtrOwner<MachiningData> pMch( MCHDATA_CREATE( nType)) ;
if ( IsNull( pMch))
return false ;
bool bOk = true ;
// assegno nome
pMch->m_sName = sName ;
CreateEgtUUID( pMch->m_Uuid) ;
// salvo i dati della lavorazione
bOk = bOk && m_umData.emplace( pMch->m_Uuid, Get( pMch)).second ;
bOk = bOk && m_suData.emplace( pMch->m_sName, pMch->m_Uuid).second ;
Release( pMch) ;
m_bModified = true ;
// la rendo la nuova lavorazione corrente
//m_tdCurrMach = pMch ;
return bOk ;
}
//----------------------------------------------------------------------------
bool
MachiningsMgr::CopyMachining( const string& sSource, const string& sName)
{
// verifico unicità del nome
if ( m_suData.find( sName) != m_suData.end())
return false ;
// recupero la lavorazione sorgente
const MachiningData* pMdata = GetMachining( sSource) ;
if ( pMdata == nullptr)
return false ;
// ne faccio una copia
PtrOwner<MachiningData> pMch( pMdata->Clone()) ;
if ( IsNull( pMch))
return false ;
bool bOk = true ;
// modifico nome e UUID
pMch->m_sName = sName ;
CreateEgtUUID( pMch->m_Uuid) ;
// salvo i dati della lavorazione
bOk = bOk && m_umData.emplace( pMch->m_Uuid, Get( pMch)).second ;
bOk = bOk && m_suData.emplace( pMch->m_sName, pMch->m_Uuid).second ;
Release( pMch) ;
//m_bModified = true ;
// la rendo la nuova lavorazione corrente
//m_bCurrMach = true ;
//m_tdCurrMach = pMch ;
return bOk ;
}
//----------------------------------------------------------------------------
bool
MachiningsMgr::RemoveMachining( const string& sName)
{
// cerco l'utensile nell'elenco dei nomi
auto iNameIter = m_suData.find( sName) ;
if ( iNameIter == m_suData.end())
return true ;
// se era anche la lavorazione corrente, la resetto
//if ( m_bCurrMach && m_tdCurrMach.m_Uuid == iNameIter->second)
// m_bCurrMach = false ;
// rimuovo la lavorazione dal dizionario degli UUID
m_umData.erase( iNameIter->second) ;
// rimuovo la lavorazione dall'elenco dei nomi
m_suData.erase( iNameIter) ;
// dichiaro la modifica
//m_bModified = true ;
return true ;
}
//----------------------------------------------------------------------------
const MachiningData*
MachiningsMgr::GetMachining( const EgtUUID& Uuid) const
@@ -345,3 +468,141 @@ MachiningsMgr::VerifyCurrMachining( int nType, string& sName) const
return false ;
}
//----------------------------------------------------------------------------
bool
MachiningsMgr::SetCurrMachining( const string& sName)
{
// se c'è lavorazione corrente, la elimino
if ( m_pCurrMach != nullptr)
delete m_pCurrMach ;
m_pCurrMach = nullptr ;
// recupero i dati della lavorazione
const MachiningData* pMdata = GetMachining( sName) ;
if ( pMdata == nullptr)
return false ;
// li copio come correnti
m_pCurrMach = pMdata->Clone() ;
return ( m_pCurrMach != nullptr) ;
}
//----------------------------------------------------------------------------
bool
MachiningsMgr::SaveCurrMachining( void)
{
// verifico validità lavorazione corrente
if ( m_pCurrMach == nullptr)
return false ;
// recupero puntatore a lavorazione corrente nel DB
auto iIter = m_umData.find( m_pCurrMach->m_Uuid) ;
if ( iIter == m_umData.end())
return false ;
// la lavorazione corrente e la sua origine nel DB devono essere dello stesso tipo
if ( m_pCurrMach->GetType() != iIter->second->GetType())
return false ;
// se cambiato nome, devo aggiornare tabella relativa
if ( m_pCurrMach->m_sName != iIter->second->m_sName) {
// cerco la lavorazione nell'elenco dei nomi
auto iNameIter = m_suData.find( iIter->second->m_sName) ;
if ( iNameIter != m_suData.end()) {
// rimuovo vecchio nome
m_suData.erase( iNameIter) ;
// inserisco nuovo
m_suData.emplace( m_pCurrMach->m_sName, m_pCurrMach->m_Uuid) ;
}
}
// eseguo salvataggio
iIter->second->CopyFrom( m_pCurrMach) ;
return true ;
}
//----------------------------------------------------------------------------
bool
MachiningsMgr::IsCurrMachiningModified( void) const
{
// verifico validità lavorazione corrente
if ( m_pCurrMach == nullptr)
return false ;
// recupero puntatore a lavorazione corrente nel DB
auto iIter = m_umData.find( m_pCurrMach->m_Uuid) ;
if ( iIter == m_umData.end())
return false ;
// eseguo confronto
return ( ! SameMachining( m_pCurrMach, iIter->second)) ;
}
//----------------------------------------------------------------------------
bool
MachiningsMgr::SetCurrMachiningParam( int nType, bool bVal)
{
return ( ( m_pCurrMach != nullptr) ? m_pCurrMach->SetParam( nType, bVal) : false) ;
}
//----------------------------------------------------------------------------
bool
MachiningsMgr::SetCurrMachiningParam( int nType, int nVal)
{
return ( ( m_pCurrMach != nullptr) ? m_pCurrMach->SetParam( nType, nVal) : false) ;
}
//----------------------------------------------------------------------------
bool
MachiningsMgr::SetCurrMachiningParam( int nType, double dVal)
{
return ( ( m_pCurrMach != nullptr) ? m_pCurrMach->SetParam( nType, dVal) : false) ;
}
//----------------------------------------------------------------------------
bool
MachiningsMgr::SetCurrMachiningParam( int nType, const std::string& sVal)
{
// deve esistere lavorazione corrente
if ( m_pCurrMach == nullptr)
return false ;
// non è possibile cambiare UUID e Tool UUID
if ( nType == MPA_UUID || nType == MPA_TUUID)
return false ;
// è possibile cambiare il nome, solo se il nuovo non è già presente nel DB (esclusa lavorazione corrente)
if ( nType == MPA_NAME) {
const MachiningData* pMch = GetMachining( sVal) ;
if ( pMch != nullptr && pMch->m_Uuid != m_pCurrMach->m_Uuid)
return false ;
}
// è possibile cambiare l'utensile, solo se esiste
else if ( nType == MPA_TOOL) {
const ToolData* pTdata ;
if ( ! m_pCurrMach->VerifyTool( m_pTsMgr, sVal, pTdata))
return false ;
return ( m_pCurrMach->SetParam( MPA_TOOL, sVal) &&
m_pCurrMach->SetParam( MPA_TUUID, ::ToString( pTdata->m_Uuid))) ;
}
// eseguo
return m_pCurrMach->SetParam( nType, sVal) ;
}
//----------------------------------------------------------------------------
bool
MachiningsMgr::GetCurrMachiningParam( int nType, bool& bVal) const
{
return ( ( m_pCurrMach != nullptr) ? m_pCurrMach->GetParam( nType, bVal) : false) ;
}
//----------------------------------------------------------------------------
bool
MachiningsMgr::GetCurrMachiningParam( int nType, int& nVal) const
{
return ( ( m_pCurrMach != nullptr) ? m_pCurrMach->GetParam( nType, nVal) : false) ;
}
//----------------------------------------------------------------------------
bool
MachiningsMgr::GetCurrMachiningParam( int nType, double& dVal) const
{
return ( ( m_pCurrMach != nullptr) ? m_pCurrMach->GetParam( nType, dVal) : false) ;
}
//----------------------------------------------------------------------------
bool
MachiningsMgr::GetCurrMachiningParam( int nType, std::string& sVal) const
{
return ( ( m_pCurrMach != nullptr) ? m_pCurrMach->GetParam( nType, sVal) : false) ;
}
+22 -5
View File
@@ -26,20 +26,34 @@ class MachiningsMgr
public :
MachiningsMgr( void) ;
~MachiningsMgr( void) ;
bool Init( const std::string& sMachsFile) ;
bool Load( void) ;
bool Load( const std::string& sMachsFile, const ToolsMgr* pTsMgr) ;
bool Save( bool bCompressed = true) const ;
bool GetMachiningNewName( std::string& sName) const ;
bool AddMachining( const std::string& sName, int nType) ;
bool CopyMachining( const std::string& sSource, const std::string& sName) ;
bool RemoveMachining( const std::string& sName) ;
const MachiningData* GetMachining( const EgtUUID& Uuid) const ;
const MachiningData* GetMachining( const std::string& sName) const ;
bool GetFirstMachining( int nType, std::string& sName) const ;
bool GetNextMachining( int nType, std::string& sName) const ;
bool SetCurrMachining( const std::string& sName) ;
bool SaveCurrMachining( void) ;
bool IsCurrMachiningModified( void) const ;
bool SetCurrMachiningParam( int nType, bool bVal) ;
bool SetCurrMachiningParam( int nType, int nVal) ;
bool SetCurrMachiningParam( int nType, double dVal) ;
bool SetCurrMachiningParam( int nType, const std::string& sVal) ;
bool GetCurrMachiningParam( int nType, bool& bVal) const ;
bool GetCurrMachiningParam( int nType, int& nVal) const ;
bool GetCurrMachiningParam( int nType, double& dVal) const ;
bool GetCurrMachiningParam( int nType, std::string& sVal) const ;
private :
bool Clear( void) ;
bool LoadHeader( Scanner& TheScanner, int& nTotal, bool& bEnd) ;
bool LoadOneMachining( Scanner& TheScanner, bool& bEnd) ;
bool LoadOneDrilling( Scanner& TheScanner, bool& bEnd) ;
bool SaveHeader( Writer& TheWriter) const ;
bool SaveOneMachining( const EgtUUID& Uuid, Writer& TheWriter) const ;
bool SaveOneMachining( const EgtUUID& Uuid, int& nCounter, Writer& TheWriter) const ;
bool VerifyCurrMachining( int nType, std::string& sName) const ;
private :
@@ -49,8 +63,11 @@ class MachiningsMgr
private :
std::string m_sMachsFile ;
const ToolsMgr* m_pTsMgr ;
UUIDPMDATA_UMAP m_umData ;
STRUUID_MAP m_suData ;
mutable STRUUID_CITER m_suCIter ;
mutable int m_nCounter ;
MachiningData* m_pCurrMach ;
mutable bool m_bModified ;
} ;
+399 -15
View File
@@ -15,6 +15,8 @@
#include "stdafx.h"
#include "MillingData.h"
#include "MachiningDataFactory.h"
#include "/EgtDev/Include/EmkToolConst.h"
#include "/EgtDev/Include/EgkGeoConst.h"
#include "/EgtDev/Include/EGnStringUtils.h"
#include <array>
#include <cassert>
@@ -38,7 +40,6 @@ enum nMillingKey {
KEY_LT,
KEY_NAME,
KEY_OL,
KEY_OM,
KEY_SA,
KEY_ST,
KEY_STY,
@@ -68,7 +69,6 @@ static const std::array<std::string,KEY_ZZZ> sMillingKey = {
"LT",
"NAME",
"OL",
"OM",
"SA",
"ST",
"STY",
@@ -82,7 +82,104 @@ static const std::array<std::string,KEY_ZZZ> sMillingKey = {
"WS"} ;
//----------------------------------------------------------------------------
MCHDATA_REGISTER( "MILLING", MillingData) ;
MCHDATA_REGISTER( MT_MILLING, "MILLING", MillingData) ;
//----------------------------------------------------------------------------
MillingData*
MillingData::Clone( void) const
{
// alloco oggetto
MillingData* pMdata = new(nothrow) MillingData ;
// copio i dati
if ( pMdata != nullptr) {
if ( ! pMdata->CopyFrom( this)) {
delete pMdata ;
return nullptr ;
}
}
return pMdata ;
}
//----------------------------------------------------------------------------
bool
MillingData::CopyFrom( const MachiningData* pMdata)
{
// è inutile copiare se sorgente coincide con destinazione
if ( pMdata == this)
return true ;
// la sorgente deve essere dello stesso tipo
const MillingData* pSdata = dynamic_cast<const MillingData*>( pMdata) ;
if ( pSdata == nullptr)
return false ;
// eseguo copia
m_Uuid = pSdata->m_Uuid ;
m_sName = pSdata->m_sName ;
m_ToolUuid = pSdata->m_ToolUuid ;
m_sToolName = pSdata->m_sToolName ;
m_bInvert = pSdata->m_bInvert ;
m_nWorkSide = pSdata->m_nWorkSide ;
m_sDepth = pSdata->m_sDepth ;
m_dOverlap = pSdata->m_dOverlap ;
m_dStep = pSdata->m_dStep ;
m_nStepType = pSdata->m_nStepType ;
m_dSideAngle = pSdata->m_dSideAngle ;
m_bLeaveTab = pSdata->m_bLeaveTab ;
m_dTabLen = pSdata->m_dTabLen ;
m_dTabDist = pSdata->m_dTabDist ;
m_dTabHeight = pSdata->m_dTabHeight ;
m_dTabAngle = pSdata->m_dTabAngle ;
m_nLeadInType = pSdata->m_nLeadInType ;
m_dLiTang = pSdata->m_dLiTang ;
m_dLiPerp = pSdata->m_dLiPerp ;
m_dLiElev = pSdata->m_dLiElev ;
m_dLiCompLen = pSdata->m_dLiCompLen ;
m_nLeadOutType = pSdata->m_nLeadOutType ;
m_dLoTang = pSdata->m_dLoTang ;
m_dLoPerp = pSdata->m_dLoPerp ;
m_dLoElev = pSdata->m_dLoElev ;
m_dLoCompLen = pSdata->m_dLoCompLen ;
return true ;
}
//----------------------------------------------------------------------------
bool
MillingData::SameAs(const MachiningData* pMdata) const
{
// se coincide con altro -> uguali
if ( pMdata == this)
return true ;
// se sono di tipo diverso -> diversi
const MillingData* pSdata = dynamic_cast<const MillingData*>( pMdata) ;
if ( pSdata == nullptr)
return false ;
// confronto termine a termine
return ( m_Uuid == pSdata->m_Uuid &&
m_sName == pSdata->m_sName &&
m_ToolUuid == pSdata->m_ToolUuid &&
m_sToolName == pSdata->m_sToolName &&
m_bInvert == pSdata->m_bInvert &&
m_nWorkSide == pSdata->m_nWorkSide &&
m_sDepth == pSdata->m_sDepth &&
m_dOverlap == pSdata->m_dOverlap &&
m_dStep == pSdata->m_dStep &&
m_nStepType == pSdata->m_nStepType &&
m_dSideAngle == pSdata->m_dSideAngle &&
m_bLeaveTab == pSdata->m_bLeaveTab &&
m_dTabLen == pSdata->m_dTabLen &&
m_dTabDist == pSdata->m_dTabDist &&
m_dTabHeight == pSdata->m_dTabHeight &&
m_dTabAngle == pSdata->m_dTabAngle &&
m_nLeadInType == pSdata->m_nLeadInType &&
m_dLiTang == pSdata->m_dLiTang &&
m_dLiPerp == pSdata->m_dLiPerp &&
m_dLiElev == pSdata->m_dLiElev &&
m_dLiCompLen == pSdata->m_dLiCompLen &&
m_nLeadOutType == pSdata->m_nLeadOutType &&
m_dLoTang == pSdata->m_dLoTang &&
m_dLoPerp == pSdata->m_dLoPerp &&
m_dLoElev == pSdata->m_dLoElev &&
m_dLoCompLen == pSdata->m_dLoCompLen) ;
}
//----------------------------------------------------------------------------
int
@@ -121,7 +218,9 @@ MillingData::FromString( const string& sString, int& nKey)
bool bOk = ( nKey >= 0) ;
switch ( nKey) {
case KEY_DH :
bOk = ::FromString( sVal, m_dDepth) ;
m_sDepth = sVal ;
if ( m_sDepth.empty())
m_sDepth = "0" ;
break ;
case KEY_INV :
bOk = ::FromString( sVal, m_bInvert) ;
@@ -136,7 +235,7 @@ MillingData::FromString( const string& sString, int& nKey)
bOk = ::FromString( sVal, m_dLiPerp) ;
break ;
case KEY_LITG :
bOk = ::FromString( sVal, m_dLiTan) ;
bOk = ::FromString( sVal, m_dLiTang) ;
break ;
case KEY_LITY :
bOk = ::FromString( sVal, m_nLeadInType) ;
@@ -151,7 +250,7 @@ MillingData::FromString( const string& sString, int& nKey)
bOk = ::FromString( sVal, m_dLoPerp) ;
break ;
case KEY_LOTG :
bOk = ::FromString( sVal, m_dLoTan) ;
bOk = ::FromString( sVal, m_dLoTang) ;
break ;
case KEY_LOTY :
bOk = ::FromString( sVal, m_nLeadOutType) ;
@@ -166,9 +265,6 @@ MillingData::FromString( const string& sString, int& nKey)
case KEY_OL :
bOk = ::FromString( sVal, m_dOverlap) ;
break ;
case KEY_OM :
bOk = ::FromString( sVal, m_dOverMat) ;
break ;
case KEY_SA :
bOk = ::FromString( sVal, m_dSideAngle) ;
break ;
@@ -192,7 +288,6 @@ MillingData::FromString( const string& sString, int& nKey)
break ;
case KEY_TNAME :
m_sToolName = sVal ;
bOk = ! m_sToolName.empty() ;
break ;
case KEY_TUUID :
bOk = ::FromString( sVal, m_ToolUuid) ;
@@ -215,22 +310,21 @@ string
MillingData::ToString( int nInd) const
{
switch ( nInd) {
case KEY_DH : return ( sMillingKey[KEY_DH] + "=" + ::ToString( m_dDepth)) ;
case KEY_DH : return ( sMillingKey[KEY_DH] + "=" + m_sDepth) ;
case KEY_INV : return ( sMillingKey[KEY_INV] + "=" + ::ToString( m_bInvert)) ;
case KEY_LICL : return ( sMillingKey[KEY_LICL] + "=" + ::ToString( m_dLiCompLen)) ;
case KEY_LIEL : return ( sMillingKey[KEY_LIEL] + "=" + ::ToString( m_dLiElev)) ;
case KEY_LIPR : return ( sMillingKey[KEY_LIPR] + "=" + ::ToString( m_dLiPerp)) ;
case KEY_LITG : return ( sMillingKey[KEY_LITG] + "=" + ::ToString( m_dLiTan)) ;
case KEY_LITG : return ( sMillingKey[KEY_LITG] + "=" + ::ToString( m_dLiTang)) ;
case KEY_LITY : return ( sMillingKey[KEY_LITY] + "=" + ::ToString( m_nLeadInType)) ;
case KEY_LOCL : return ( sMillingKey[KEY_LOCL] + "=" + ::ToString( m_dLoCompLen)) ;
case KEY_LOEL : return ( sMillingKey[KEY_LOEL] + "=" + ::ToString( m_dLoElev)) ;
case KEY_LOPR : return ( sMillingKey[KEY_LOPR] + "=" + ::ToString( m_dLoPerp)) ;
case KEY_LOTG : return ( sMillingKey[KEY_LOTG] + "=" + ::ToString( m_dLoTan)) ;
case KEY_LOTG : return ( sMillingKey[KEY_LOTG] + "=" + ::ToString( m_dLoTang)) ;
case KEY_LOTY : return ( sMillingKey[KEY_LOTY] + "=" + ::ToString( m_nLeadOutType)) ;
case KEY_LT : return ( sMillingKey[KEY_LT] + "=" + ::ToString( m_bLeaveTab)) ;
case KEY_NAME : return ( sMillingKey[KEY_NAME] + "=" + m_sName) ;
case KEY_OL : return ( sMillingKey[KEY_OL] + "=" + ::ToString( m_dOverlap)) ;
case KEY_OM : return ( sMillingKey[KEY_OM] + "=" + ::ToString( m_dOverMat)) ;
case KEY_SA : return ( sMillingKey[KEY_SA] + "=" + ::ToString( m_dSideAngle)) ;
case KEY_ST : return ( sMillingKey[KEY_ST] + "=" + ::ToString( m_dStep)) ;
case KEY_STY : return ( sMillingKey[KEY_STY] + "=" + ::ToString( m_nStepType)) ;
@@ -244,4 +338,294 @@ MillingData::ToString( int nInd) const
case KEY_WS : return ( sMillingKey[KEY_WS] + "=" + ::ToString( m_nWorkSide)) ;
default : return "" ;
}
}
}
//----------------------------------------------------------------------------
bool
MillingData::VerifyWorkSide( int nVal) const
{
return ( nVal == MILL_WS_CENTER || nVal == MILL_WS_LEFT || nVal == MILL_WS_RIGHT) ;
}
//----------------------------------------------------------------------------
bool
MillingData::VerifyStepType( int nVal) const
{
return ( nVal == MILL_ST_STEP || nVal == MILL_ST_ONEWAY || nVal == MILL_ST_SPIRAL) ;
}
//----------------------------------------------------------------------------
bool
MillingData::VerifyLeadInType( int nVal) const
{
return ( nVal == MILL_LI_NONE || nVal == MILL_LI_LINEAR ||
nVal == MILL_LI_TANGENT || nVal == MILL_LI_GLIDE) ;
}
//----------------------------------------------------------------------------
bool
MillingData::VerifyLeadOutType( int nVal) const
{
return ( nVal == MILL_LO_NONE || nVal == MILL_LO_LINEAR ||
nVal == MILL_LO_TANGENT || nVal == MILL_LO_GLIDE || nVal == MILL_LO_AS_LI) ;
}
//----------------------------------------------------------------------------
bool
MillingData::VerifySideAngle( double dVal) const
{
return ( ( dVal > - EPS_SMALL && dVal < 90 + EPS_SMALL) || fabs( dVal - 99) < EPS_SMALL) ;
}
//----------------------------------------------------------------------------
bool
MillingData::VerifyTool( const ToolsMgr* pToolsMgr, const std::string& sVal, const ToolData*& pTdata) const
{
if ( pToolsMgr == nullptr)
return false ;
pTdata = pToolsMgr->GetTool( sVal) ;
if ( pTdata == nullptr)
return false ;
if ( ( pTdata->m_nType & TF_MILL) == 0 && ( pTdata->m_nType & TF_SAWBLADE) == 0)
return false ;
return true ;
}
//----------------------------------------------------------------------------
bool
MillingData::SetParam( int nType, bool bVal)
{
switch ( nType) {
case MPA_INVERT :
m_bInvert = bVal ;
return true ;
case MPA_LEAVETAB :
m_bLeaveTab = bVal ;
return true ;
}
return false ;
}
//----------------------------------------------------------------------------
bool
MillingData::SetParam( int nType, int nVal)
{
switch ( nType) {
case MPA_WORKSIDE :
if ( ! VerifyWorkSide( nVal))
return false ;
m_nWorkSide = nVal ;
return true ;
case MPA_STEPTYPE :
if ( ! VerifyStepType( nVal))
return false ;
m_nStepType = nVal ;
return true ;
case MPA_LEADINTYPE :
if ( ! VerifyLeadInType( nVal))
return false ;
m_nLeadInType = nVal ;
return true ;
case MPA_LEADOUTTYPE :
if ( ! VerifyLeadOutType( nVal))
return false ;
m_nLeadOutType = nVal ;
return true ;
}
return false ;
}
//----------------------------------------------------------------------------
bool
MillingData::SetParam( int nType, double dVal)
{
switch ( nType) {
case MPA_DEPTH :
m_sDepth = ::ToString( dVal) ;
return true ;
case MPA_OVERLAP :
m_dOverlap = dVal ;
return true ;
case MPA_STEP :
m_dStep = dVal ;
return true ;
case MPA_SIDEANGLE :
if ( ! VerifySideAngle( dVal))
return false ;
m_dSideAngle = dVal ;
return true ;
case MPA_TABLEN :
m_dTabLen = dVal ;
return true ;
case MPA_TABDIST :
m_dTabDist = dVal ;
return true ;
case MPA_TABHEIGHT :
m_dTabHeight = dVal ;
return true ;
case MPA_TABANGLE :
m_dTabAngle = dVal ;
return true ;
case MPA_LITANG :
m_dLiTang = dVal ;
return true ;
case MPA_LIPERP :
m_dLiPerp = dVal ;
return true ;
case MPA_LIELEV :
m_dLiElev = dVal ;
return true ;
case MPA_LICOMPLEN :
m_dLiCompLen = dVal ;
return true ;
case MPA_LOTANG :
m_dLoTang = dVal ;
return true ;
case MPA_LOPERP :
m_dLoPerp = dVal ;
return true ;
case MPA_LOELEV :
m_dLoElev = dVal ;
return true ;
case MPA_LOCOMPLEN :
m_dLoCompLen = dVal ;
return true ;
}
return false ;
}
//----------------------------------------------------------------------------
bool
MillingData::SetParam( int nType, const string& sVal)
{
switch ( nType) {
case MPA_NAME :
m_sName = sVal ;
return true ;
case MPA_TOOL :
m_sToolName = sVal ;
return true ;
case MPA_DEPTH_STR :
m_sDepth = sVal ;
return true ;
case MPA_TUUID :
return ::FromString( sVal, m_ToolUuid) ;
case MPA_UUID :
return ::FromString( sVal, m_Uuid) ;
}
return false ;
}
//----------------------------------------------------------------------------
bool
MillingData::GetParam( int nType, bool& bVal) const
{
switch ( nType) {
case MPA_INVERT :
bVal = m_bInvert ;
return true ;
case MPA_LEAVETAB :
bVal = m_bLeaveTab ;
return true ;
}
return false ;
}
//----------------------------------------------------------------------------
bool
MillingData::GetParam( int nType, int& nVal) const
{
switch ( nType) {
case MPA_WORKSIDE :
nVal = m_nWorkSide ;
return true ;
case MPA_STEPTYPE :
nVal = m_nStepType ;
return true ;
case MPA_LEADINTYPE :
nVal = m_nLeadInType ;
return true ;
case MPA_LEADOUTTYPE :
nVal = m_nLeadOutType ;
return true ;
}
return false ;
}
//----------------------------------------------------------------------------
bool
MillingData::GetParam( int nType, double& dVal) const
{
switch ( nType) {
case MPA_OVERLAP :
dVal = m_dOverlap ;
return true ;
case MPA_STEP :
dVal = m_dStep ;
return true ;
case MPA_SIDEANGLE :
dVal = m_dSideAngle ;
return true ;
case MPA_TABLEN :
dVal = m_dTabLen ;
return true ;
case MPA_TABDIST :
dVal = m_dTabDist ;
return true ;
case MPA_TABHEIGHT :
dVal = m_dTabHeight ;
return true ;
case MPA_TABANGLE :
dVal = m_dTabAngle ;
return true ;
case MPA_LITANG :
dVal = m_dLiTang ;
return true ;
case MPA_LIPERP :
dVal = m_dLiPerp ;
return true ;
case MPA_LIELEV :
dVal = m_dLiElev ;
return true ;
case MPA_LICOMPLEN :
dVal = m_dLiCompLen ;
return true ;
case MPA_LOTANG :
dVal = m_dLoTang ;
return true ;
case MPA_LOPERP :
dVal = m_dLoPerp ;
return true ;
case MPA_LOELEV :
dVal = m_dLoElev ;
return true ;
case MPA_LOCOMPLEN :
dVal = m_dLoCompLen ;
return true ;
}
return false ;
}
//----------------------------------------------------------------------------
bool
MillingData::GetParam( int nType, string& sVal) const
{
switch ( nType) {
case MPA_NAME :
sVal = m_sName ;
return true ;
case MPA_TOOL :
sVal = m_sToolName ;
return true ;
case MPA_DEPTH_STR :
sVal = m_sDepth ;
return true ;
case MPA_TUUID :
sVal = ::ToString( m_ToolUuid) ;
return true ;
case MPA_UUID :
sVal = ::ToString( m_Uuid) ;
return true ;
}
return false ;
}
+24 -8
View File
@@ -22,8 +22,7 @@ struct MillingData : public MachiningData
std::string m_sToolName ; // nome dell'utensile
bool m_bInvert ; // flag di inversione direzione lavorazione
int m_nWorkSide ; // lato di lavoro (destra, sinistra, centro)
double m_dOverMat ; // sovramateriale radiale
double m_dDepth ; // affondamento
std::string m_sDepth ; // affondamento (espressione numerica)
double m_dOverlap ; // lunghezza di sovrapposizione se percorso chiuso
double m_dStep ; // passo di affondamento (0=nessun passo)
int m_nStepType ; // tipo di lavorazione a step (a gradini, una via, a spirale)
@@ -34,26 +33,43 @@ struct MillingData : public MachiningData
double m_dTabHeight ; // altezza dei tab
double m_dTabAngle ; // angolo di salita/discesa dei tab
int m_nLeadInType ; // tipo di attacco (nessuno, lineare, tangente, inseguimento)
double m_dLiTan ; // distanza tangente da inizio attacco
double m_dLiTang ; // distanza tangente da inizio attacco
double m_dLiPerp ; // distanza perpendicolare da inizio attacco
double m_dLiElev ; // elevazione da inizio attacco
double m_dLiCompLen ; // lunghezza del tratto di inserimento correttore raggio utensile
int m_nLeadOutType ; // tipo di uscita (come attacco, nessuno, lineare, tangente, inseguimento)
double m_dLoTan ; // distanza tangente verso fine uscita
double m_dLoTang ; // distanza tangente verso fine uscita
double m_dLoPerp ; // distanza perpendicolare verso fine uscita
double m_dLoElev ; // elevazione verso fine uscita
double m_dLoCompLen ; // lunghezza del tratto di disinserimento correttore raggio utensile
MillingData( void)
: m_bInvert( false), m_nWorkSide( 0),
m_dOverMat( 0), m_dDepth( 0), m_dOverlap( 0), m_dStep( 0), m_nStepType( 0), m_dSideAngle( 0),
m_bLeaveTab( false), m_dTabLen( 0), m_dTabDist( 0), m_dTabHeight( 0), m_dTabAngle( 0),
m_nLeadInType( 0), m_dLiTan( 0), m_dLiPerp( 0), m_dLiElev( 0), m_dLiCompLen( 0),
m_nLeadOutType( 0), m_dLoTan( 0), m_dLoPerp( 0), m_dLoElev( 0), m_dLoCompLen( 0) {}
m_dOverlap( 0), m_dStep( 0), m_nStepType( 0), m_dSideAngle( 0),
m_bLeaveTab( false), m_dTabLen( 0), m_dTabDist( 0), m_dTabHeight( 0), m_dTabAngle( 0),
m_nLeadInType( 0), m_dLiTang( 0), m_dLiPerp( 0), m_dLiElev( 0), m_dLiCompLen( 0),
m_nLeadOutType( 0), m_dLoTang( 0), m_dLoPerp( 0), m_dLoElev( 0), m_dLoCompLen( 0) {}
virtual MillingData* Clone( void) const ;
virtual bool CopyFrom( const MachiningData* pMdata) ;
virtual bool SameAs(const MachiningData* pMdata) const ;
virtual int GetType( void) const { return MT_MILLING ; }
virtual int GetSize( void) const ;
virtual std::string GetTitle( void) const ;
virtual bool FromString( const std::string& sString, int& nKey) ;
virtual std::string ToString( int nInd) const ;
virtual bool SetParam( int nType, bool bVal) ;
virtual bool SetParam( int nType, int nVal) ;
virtual bool SetParam( int nType, double dVal) ;
virtual bool SetParam( int nType, const std::string& sVal) ;
virtual bool GetParam( int nType, bool& bVal) const ;
virtual bool GetParam( int nType, int& nVal) const ;
virtual bool GetParam( int nType, double& dVal) const ;
virtual bool GetParam( int nType, std::string& sVal) const ;
virtual bool VerifyTool( const ToolsMgr* pToolsMgr, const std::string& sVal, const ToolData*& pTdata) const ;
bool VerifyWorkSide( int nVal) const ;
bool VerifyStepType( int nVal) const ;
bool VerifyLeadInType( int nVal) const ;
bool VerifyLeadOutType( int nVal) const ;
bool VerifySideAngle( double dVal) const ;
} ;
//----------------------------------------------------------------------------
+25 -33
View File
@@ -169,14 +169,12 @@ Sawing::SetParam( int nType, bool bVal)
switch ( nType) {
case MPA_INVERT :
m_Params.m_bInvert = bVal ;
break ;
return true ;
case MPA_TOANDFROM :
m_Params.m_bToAndFrom = bVal ;
break ;
default :
return false ;
return true ;
}
return true ;
return false ;
}
//----------------------------------------------------------------------------
@@ -188,36 +186,34 @@ Sawing::SetParam( int nType, int nVal)
if ( ! m_Params.VerifyWorkSide( nVal))
return false ;
m_Params.m_nWorkSide = nVal ;
break ;
return true ;
case MPA_HEADSIDE :
if ( ! m_Params.VerifyHeadSide( nVal))
return false ;
m_Params.m_nHeadSide = nVal ;
break ;
return true ;
case MPA_LEADINTYPE :
if ( ! m_Params.VerifyLeadInType( nVal))
return false ;
m_Params.m_nLeadInType = nVal ;
break ;
return true ;
case MPA_EXTLINKTYPE :
if ( ! m_Params.VerifyExtLinkType( nVal))
return false ;
m_Params.m_nExtLinkType = nVal ;
break ;
return true ;
case MPA_LEADOUTTYPE :
if ( ! m_Params.VerifyLeadOutType( nVal))
return false ;
m_Params.m_nLeadOutType = nVal ;
break ;
return true ;
case MPA_CURVEUSE :
if ( ! m_Params.VerifyCurveUse( nVal))
return false ;
m_Params.m_nCurveUse = nVal ;
break ;
default :
return false ;
return true ;
}
return true ;
return false ;
}
//----------------------------------------------------------------------------
@@ -229,40 +225,38 @@ Sawing::SetParam( int nType, double dVal)
if ( ! m_TParams.VerifySpeed( dVal))
return false ;
m_TParams.m_dSpeed = dVal ;
break ;
return true ;
case MPA_TOOLFEED :
m_TParams.m_dFeed = dVal ;
break ;
return true ;
case MPA_TOOLSTARTFEED :
m_TParams.m_dStartFeed = dVal ;
break ;
return true ;
case MPA_TOOLENDFEED :
m_TParams.m_dEndFeed = dVal ;
break ;
return true ;
case MPA_TOOLTIPFEED :
m_TParams.m_dTipFeed = dVal ;
break ;
return true ;
case MPA_TOOLOFFSR :
m_TParams.m_dOffsR = dVal ;
break ;
return true ;
case MPA_TOOLOFFSL :
m_TParams.m_dOffsL = dVal ;
break ;
return true ;
case MPA_DEPTH :
m_Params.m_sDepth = ToString( dVal) ;
break ;
return true ;
case MPA_SIDEANGLE :
if ( ! m_Params.VerifySideAngle( dVal))
return false ;
m_Params.m_dSideAngle = dVal ;
break ;
return true ;
case MPA_APPROX :
m_Params.m_dApprox = dVal ;
break ;
default :
return false ;
return true ;
}
return true ;
return false ;
}
//----------------------------------------------------------------------------
@@ -272,19 +266,17 @@ Sawing::SetParam( int nType, const string& sVal)
switch ( nType) {
case MPA_TOOL : {
const ToolData* pTdata ;
if ( ! m_Params.VerifyTool( m_pMchMgr, sVal, pTdata))
if ( ! m_Params.VerifyTool( m_pMchMgr->GetCurrToolsMgr(), sVal, pTdata))
return false ;
m_Params.m_sToolName = sVal ;
m_Params.m_ToolUuid = pTdata->m_Uuid ;
m_TParams = *pTdata ;
} break ;
} return true ;
case MPA_DEPTH_STR :
m_Params.m_sDepth = sVal ;
break ;
default :
return false ;
return true ;
}
return true ;
return false ;
}
//----------------------------------------------------------------------------
+254 -10
View File
@@ -15,7 +15,6 @@
#include "stdafx.h"
#include "SawingData.h"
#include "MachiningDataFactory.h"
#include "/EgtDev/Include/EMkMachiningConst.h"
#include "/EgtDev/Include/EmkToolConst.h"
#include "/EgtDev/Include/EGkGeoConst.h"
#include "/EgtDev/Include/EGnStringUtils.h"
@@ -61,7 +60,78 @@ static const std::array<std::string,KEY_ZZZ> sSawingKey = {
"WS"} ;
//----------------------------------------------------------------------------
MCHDATA_REGISTER( "SAWING", SawingData) ;
MCHDATA_REGISTER( MT_SAWING, "SAWING", SawingData) ;
//----------------------------------------------------------------------------
SawingData*
SawingData::Clone( void) const
{
// alloco oggetto
SawingData* pSdata = new(nothrow) SawingData ;
// copio i dati
if ( pSdata != nullptr) {
}
return pSdata ;
}
//----------------------------------------------------------------------------
bool
SawingData::CopyFrom( const MachiningData* pMdata)
{
// è inutile copiare se sorgente coincide con destinazione
if ( pMdata == this)
return true ;
// la sorgente deve essere dello stesso tipo
const SawingData* pSdata = dynamic_cast<const SawingData*>( pMdata) ;
if ( pSdata == nullptr)
return false ;
// eseguo copia
m_Uuid = pSdata->m_Uuid ;
m_sName = pSdata->m_sName ;
m_ToolUuid = pSdata->m_ToolUuid ;
m_sToolName = pSdata->m_sToolName ;
m_bInvert = pSdata->m_bInvert ;
m_nWorkSide = pSdata->m_nWorkSide ;
m_nHeadSide = pSdata->m_nHeadSide ;
m_bToAndFrom = pSdata->m_bToAndFrom ;
m_sDepth = pSdata->m_sDepth ;
m_dSideAngle = pSdata->m_dSideAngle ;
m_nLeadInType = pSdata->m_nLeadInType ;
m_nExtLinkType = pSdata->m_nExtLinkType ;
m_nLeadOutType = pSdata->m_nLeadOutType ;
m_nCurveUse = pSdata->m_nCurveUse ;
m_dApprox = pSdata->m_dApprox ;
return true ;
}
//----------------------------------------------------------------------------
bool
SawingData::SameAs(const MachiningData* pMdata) const
{
// se coincide con altro -> uguali
if ( pMdata == this)
return true ;
// se sono di tipo diverso -> diversi
const SawingData* pSdata = dynamic_cast<const SawingData*>( pMdata) ;
if ( pSdata == nullptr)
return false ;
// confronto termine a termine
return ( m_Uuid == pSdata->m_Uuid &&
m_sName == pSdata->m_sName &&
m_ToolUuid == pSdata->m_ToolUuid &&
m_sToolName == pSdata->m_sToolName &&
m_bInvert == pSdata->m_bInvert &&
m_nWorkSide == pSdata->m_nWorkSide &&
m_nHeadSide == pSdata->m_nHeadSide &&
m_bToAndFrom == pSdata->m_bToAndFrom &&
m_sDepth == pSdata->m_sDepth &&
m_dSideAngle == pSdata->m_dSideAngle &&
m_nLeadInType == pSdata->m_nLeadInType &&
m_nExtLinkType == pSdata->m_nExtLinkType &&
m_nLeadOutType == pSdata->m_nLeadOutType &&
m_nCurveUse == pSdata->m_nCurveUse &&
m_dApprox == pSdata->m_dApprox) ;
}
//----------------------------------------------------------------------------
int
@@ -107,7 +177,8 @@ SawingData::FromString( const string& sString, int& nKey)
break ;
case KEY_DH :
m_sDepth = sVal ;
bOk = ! m_sDepth.empty() ;
if ( m_sDepth.empty())
m_sDepth = "0" ;
break ;
case KEY_HS :
bOk = ::FromString( sVal, m_nHeadSide) ;
@@ -136,7 +207,6 @@ SawingData::FromString( const string& sString, int& nKey)
break ;
case KEY_TNAME :
m_sToolName = sVal ;
bOk = ! m_sToolName.empty() ;
break ;
case KEY_TUUID :
bOk = ::FromString( sVal, m_ToolUuid) ;
@@ -231,17 +301,191 @@ SawingData::VerifySideAngle( double dVal) const
//----------------------------------------------------------------------------
bool
SawingData::VerifyTool( MachMgr* pMachMgr, const std::string& sVal, const ToolData*& pTdata) const
SawingData::VerifyTool( const ToolsMgr* pToolsMgr, const std::string& sVal, const ToolData*& pTdata) const
{
if ( pMachMgr == nullptr)
if ( pToolsMgr == nullptr)
return false ;
ToolsMgr* pTMgr = pMachMgr->GetCurrToolsMgr() ;
if ( pTMgr == nullptr)
return false ;
pTdata = pTMgr->GetTool( sVal) ;
pTdata = pToolsMgr->GetTool( sVal) ;
if ( pTdata == nullptr)
return false ;
if ( ( pTdata->m_nType & TF_SAWBLADE) == 0)
return false ;
return true ;
}
//----------------------------------------------------------------------------
bool
SawingData::SetParam( int nType, bool bVal)
{
switch ( nType) {
case MPA_INVERT :
m_bInvert = bVal ;
return true ;
case MPA_TOANDFROM :
m_bToAndFrom = bVal ;
return true ;
}
return false ;
}
//----------------------------------------------------------------------------
bool
SawingData::SetParam( int nType, int nVal)
{
switch ( nType) {
case MPA_WORKSIDE :
if ( ! VerifyWorkSide( nVal))
return false ;
m_nWorkSide = nVal ;
return true ;
case MPA_HEADSIDE :
if ( ! VerifyHeadSide( nVal))
return false ;
m_nHeadSide = nVal ;
return true ;
case MPA_LEADINTYPE :
if ( ! VerifyLeadInType( nVal))
return false ;
m_nLeadInType = nVal ;
return true ;
case MPA_EXTLINKTYPE :
if ( ! VerifyExtLinkType( nVal))
return false ;
m_nExtLinkType = nVal ;
return true ;
case MPA_LEADOUTTYPE :
if ( ! VerifyLeadOutType( nVal))
return false ;
m_nLeadOutType = nVal ;
return true ;
case MPA_CURVEUSE :
if ( ! VerifyCurveUse( nVal))
return false ;
m_nCurveUse = nVal ;
return true ;
}
return false ;
}
//----------------------------------------------------------------------------
bool
SawingData::SetParam( int nType, double dVal)
{
switch ( nType) {
case MPA_DEPTH :
m_sDepth = ::ToString( dVal) ;
return true ;
case MPA_SIDEANGLE :
if ( ! VerifySideAngle( dVal))
return false ;
m_dSideAngle = dVal ;
return true ;
case MPA_APPROX :
m_dApprox = dVal ;
return true ;
}
return false ;
}
//----------------------------------------------------------------------------
bool
SawingData::SetParam( int nType, const string& sVal)
{
switch ( nType) {
case MPA_NAME :
m_sName = sVal ;
return true ;
case MPA_TOOL :
m_sToolName = sVal ;
return true ;
case MPA_DEPTH_STR :
m_sDepth = sVal ;
return true ;
case MPA_TUUID :
return ::FromString( sVal, m_ToolUuid) ;
case MPA_UUID :
return ::FromString( sVal, m_Uuid) ;
}
return false ;
}
//----------------------------------------------------------------------------
bool
SawingData::GetParam( int nType, bool& bVal) const
{
switch ( nType) {
case MPA_INVERT :
bVal = m_bInvert ;
return true ;
case MPA_TOANDFROM :
bVal = m_bToAndFrom ;
return true ;
}
return false ;
}
//----------------------------------------------------------------------------
bool
SawingData::GetParam( int nType, int& nVal) const
{
switch ( nType) {
case MPA_WORKSIDE :
nVal = m_nWorkSide ;
return true ;
case MPA_HEADSIDE :
nVal = m_nHeadSide ;
return true ;
case MPA_LEADINTYPE :
nVal = m_nLeadInType ;
return true ;
case MPA_EXTLINKTYPE :
nVal = m_nExtLinkType ;
return true ;
case MPA_LEADOUTTYPE :
nVal = m_nLeadOutType ;
return true ;
case MPA_CURVEUSE :
nVal = m_nCurveUse ;
return true ;
}
return false ;
}
//----------------------------------------------------------------------------
bool
SawingData::GetParam( int nType, double& dVal) const
{
switch ( nType) {
case MPA_SIDEANGLE :
dVal = m_dSideAngle ;
return true ;
case MPA_APPROX :
dVal = m_dApprox ;
return true ;
}
return false ;
}
//----------------------------------------------------------------------------
bool
SawingData::GetParam( int nType, string& sVal) const
{
switch ( nType) {
case MPA_NAME :
sVal = m_sName ;
return true ;
case MPA_TOOL :
sVal = m_sToolName ;
return true ;
case MPA_DEPTH_STR :
sVal = m_sDepth ;
return true ;
case MPA_TUUID :
sVal = ::ToString( m_ToolUuid) ;
return true ;
case MPA_UUID :
sVal = ::ToString( m_Uuid) ;
return true ;
}
return false ;
}
+12 -4
View File
@@ -14,7 +14,6 @@
#pragma once
#include "MachiningData.h"
#include "MachMgr.h"
//----------------------------------------------------------------------------
struct SawingData : public MachiningData
@@ -36,13 +35,23 @@ struct SawingData : public MachiningData
SawingData( void)
: m_bInvert( false), m_nWorkSide( 0), m_nHeadSide(0), m_bToAndFrom( false), m_dSideAngle( 0),
m_nLeadInType( 0), m_nExtLinkType( 0), m_nLeadOutType( 0), m_nCurveUse( 0), m_dApprox( 0) {}
virtual SawingData* Clone( void) const ;
virtual bool CopyFrom( const MachiningData* pMdata) ;
virtual bool SameAs(const MachiningData* pMdata) const ;
virtual int GetType( void) const { return MT_SAWING ; }
virtual int GetSize( void) const ;
virtual std::string GetTitle( void) const ;
virtual bool FromString( const std::string& sString, int& nKey) ;
virtual std::string ToString( int nInd) const ;
virtual bool SetParam( int nType, bool bVal) ;
virtual bool SetParam( int nType, int nVal) ;
virtual bool SetParam( int nType, double dVal) ;
virtual bool SetParam( int nType, const std::string& sVal) ;
virtual bool GetParam( int nType, bool& bVal) const ;
virtual bool GetParam( int nType, int& nVal) const ;
virtual bool GetParam( int nType, double& dVal) const ;
virtual bool GetParam( int nType, std::string& sVal) const ;
virtual bool VerifyTool( const ToolsMgr* pToolsMgr, const std::string& sVal, const ToolData*& pTdata) const ;
bool VerifyWorkSide( int nVal) const ;
bool VerifyHeadSide( int nVal) const ;
bool VerifyLeadInType( int nVal) const ;
@@ -50,7 +59,6 @@ struct SawingData : public MachiningData
bool VerifyLeadOutType( int nVal) const ;
bool VerifyCurveUse( int nVal) const ;
bool VerifySideAngle( double dVal) const ;
bool VerifyTool( MachMgr* pMachMgr, const std::string& sVal, const ToolData*& pTdata) const ;
} ;
//----------------------------------------------------------------------------
+14
View File
@@ -257,6 +257,13 @@ ToolData::VerifySpeed( double dVal) const
return ( dVal < m_dMaxSpeed + EPS_SMALL) ;
}
//----------------------------------------------------------------------------
bool
ToolData::SetParam( int nType, bool bVal)
{
return false ;
}
//----------------------------------------------------------------------------
bool
ToolData::SetParam( int nType, int nVal)
@@ -374,6 +381,13 @@ ToolData::SetParam( int nType, const string& sVal)
return false ;
}
//----------------------------------------------------------------------------
bool
ToolData::GetParam( int nType, bool& bVal) const
{
return false ;
}
//----------------------------------------------------------------------------
bool
ToolData::GetParam( int nType, int& nVal) const
+2 -1
View File
@@ -58,11 +58,12 @@ struct ToolData
static int GetSize( void) ;
bool FromString( const std::string& sString, int& nKey) ;
std::string ToString( int nInd) const ;
bool VerifySpeed( double dVal) const ;
bool SetParam( int nType, bool bVal) ;
bool SetParam( int nType, int nVal) ;
bool SetParam( int nType, double dVal) ;
bool SetParam( int nType, const std::string& sVal) ;
bool GetParam( int nType, bool& bVal) const ;
bool GetParam( int nType, int& nVal) const ;
bool GetParam( int nType, double& dVal) const ;
bool GetParam( int nType, std::string& sVal) const ;
+36 -7
View File
@@ -347,7 +347,7 @@ ToolsMgr::AddTool( const string& sName, int nType)
//----------------------------------------------------------------------------
bool
ToolsMgr::CopyTool( const std::string& sSource, const std::string& sName)
ToolsMgr::CopyTool( const string& sSource, const string& sName)
{
// verifico unicità del nome
if ( m_suData.find( sName) != m_suData.end())
@@ -362,10 +362,10 @@ ToolsMgr::CopyTool( const std::string& sSource, const std::string& sName)
tData.m_sName = sName ;
CreateEgtUUID( tData.m_Uuid) ;
// salvo i dati del nuovo utensile
m_bModified = true ;
if ( ! m_utData.emplace( tData.m_Uuid, tData).second ||
! m_suData.emplace( tData.m_sName, tData.m_Uuid).second)
return false ;
m_bModified = true ;
// lo rendo il nuovo utensile corrente
m_bCurrTool = true ;
m_tdCurrTool = tData ;
@@ -490,6 +490,17 @@ ToolsMgr::SaveCurrTool( void)
auto iIter = m_utData.find( m_tdCurrTool.m_Uuid) ;
if ( iIter == m_utData.end())
return false ;
// se cambiato nome, devo aggiornare tabella relativa
if ( m_tdCurrTool.m_sName != iIter->second.m_sName) {
// cerco l'utensile nell'elenco dei nomi
auto iNameIter = m_suData.find( iIter->second.m_sName) ;
if ( iNameIter != m_suData.end()) {
// rimuovo vecchio nome
m_suData.erase( iNameIter) ;
// inserisco nuovo
m_suData.emplace( m_tdCurrTool.m_sName, m_tdCurrTool.m_Uuid) ;
}
}
// eseguo salvataggio
m_bModified = true ;
iIter->second = m_tdCurrTool ;
@@ -498,7 +509,7 @@ ToolsMgr::SaveCurrTool( void)
//----------------------------------------------------------------------------
bool
ToolsMgr::IsCurrToolModified( void)
ToolsMgr::IsCurrToolModified( void) const
{
// verifico validità utensile corrente
if ( ! m_bCurrTool)
@@ -508,7 +519,14 @@ ToolsMgr::IsCurrToolModified( void)
if ( iIter == m_utData.end())
return false ;
// eseguo confronto
return ! SameTool( m_tdCurrTool, iIter->second) ;
return ( ! SameTool( m_tdCurrTool, iIter->second)) ;
}
//----------------------------------------------------------------------------
bool
ToolsMgr::SetCurrToolParam( int nType, bool bVal)
{
return ( m_bCurrTool ? m_tdCurrTool.SetParam( nType, bVal) : false) ;
}
//----------------------------------------------------------------------------
@@ -529,16 +547,27 @@ ToolsMgr::SetCurrToolParam( int nType, double dVal)
bool
ToolsMgr::SetCurrToolParam( int nType, const string& sVal)
{
// deve esistere utensile corrente
if ( ! m_bCurrTool)
return false ;
// non è possibile cambiare UUID
if ( nType == TPA_UUID)
return false ;
// è possibile cambiare il nome, solo se il nuovo non è già presente nel DB
// è possibile cambiare il nome, solo se il nuovo non è già presente nel DB (escluso utensile corrente)
if ( nType == TPA_NAME) {
if ( GetTool( sVal) != nullptr)
const ToolData* pTdata = GetTool( sVal) ;
if ( pTdata != nullptr && pTdata->m_Uuid != m_tdCurrTool.m_Uuid)
return false ;
}
// eseguo
return ( m_bCurrTool ? m_tdCurrTool.SetParam( nType, sVal) : false) ;
return m_tdCurrTool.SetParam( nType, sVal) ;
}
//----------------------------------------------------------------------------
bool
ToolsMgr::GetCurrToolParam( int nType, bool& bVal) const
{
return ( m_bCurrTool ? m_tdCurrTool.GetParam( nType, bVal) : false) ;
}
//----------------------------------------------------------------------------
+3 -1
View File
@@ -37,10 +37,12 @@ class ToolsMgr
bool GetNextTool( int nFamily, std::string& sName, int& nType) const ;
bool SetCurrTool( const std::string& sName) ;
bool SaveCurrTool( void) ;
bool IsCurrToolModified( void) ;
bool IsCurrToolModified( void) const ;
bool SetCurrToolParam( int nType, bool bVal) ;
bool SetCurrToolParam( int nType, int nVal) ;
bool SetCurrToolParam( int nType, double dVal) ;
bool SetCurrToolParam( int nType, const std::string& sVal) ;
bool GetCurrToolParam( int nType, bool& bVal) const ;
bool GetCurrToolParam( int nType, int& nVal) const ;
bool GetCurrToolParam( int nType, double& dVal) const ;
bool GetCurrToolParam( int nType, std::string& sVal) const ;