EgtMachKernel 1.6n4 :

- migliorie a gestione fasi
- migliorie a gestione spezzatura grezzi.
This commit is contained in:
Dario Sassi
2016-02-15 07:45:43 +00:00
parent a8c34397be
commit bbb25a4fec
10 changed files with 409 additions and 83 deletions
+159 -40
View File
@@ -151,19 +151,19 @@ MachMgr::GetPrevActiveOperation( int nId) const
int
MachMgr::GetOperationType( int nId) const
{
// recupero il gruppo delle operazioni nella macchinata corrente
int nOperGrpId = GetCurrOperId() ;
if ( nOperGrpId == GDB_ID_NULL)
// recupero l'operazione
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGeomDB)) ;
if ( IsNull( pIter) || ! pIter->GoTo( nId))
return OPER_NULL ;
// verifico che il gruppo ricevuto sia corretto
if ( m_pGeomDB->GetParentId( nId) != nOperGrpId)
if ( pIter->GetParentId() != GetCurrOperId())
return OPER_NULL ;
// recupero user object
IUserObj* pUserObj = m_pGeomDB->GetUserObj( nId) ;
IUserObj* pUserObj = pIter->GetUserObj() ;
if ( pUserObj == nullptr)
return OPER_NULL ;
// recupero il tipo di UserObj
string sUserObj = pUserObj->GetClassName() ;
const string& sUserObj = pUserObj->GetClassName() ;
if ( sUserObj == USEROBJ_GETNAME( Disposition))
return OPER_DISP ;
else if ( sUserObj == USEROBJ_GETNAME( Drilling))
@@ -176,6 +176,37 @@ MachMgr::GetOperationType( int nId) const
return OPER_NULL ;
}
//----------------------------------------------------------------------------
int
MachMgr::GetOperationPhase( int nId) const
{
// recupero l'operazione
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGeomDB)) ;
if ( IsNull( pIter) || ! pIter->GoTo( nId))
return 0 ;
// verifico che il gruppo ricevuto sia corretto
if ( pIter->GetParentId() != GetCurrOperId())
return 0 ;
// recupero user object
IUserObj* pUserObj = pIter->GetUserObj() ;
if ( pUserObj == nullptr)
return 0 ;
// se disposizione
if ( pUserObj->GetClassName() == USEROBJ_GETNAME( Disposition)) {
const Disposition* pDisp = ::GetDisposition( pUserObj) ;
if ( pDisp != nullptr)
return pDisp->GetPhase() ;
}
// altrimenti lavorazione
else {
const Machining* pMch = GetMachining( pUserObj) ;
if ( pMch != nullptr)
return pMch->GetPhase() ;
}
// errore
return 0 ;
}
//----------------------------------------------------------------------------
bool
MachMgr::GetOperationNewName( string& sName) const
@@ -203,16 +234,16 @@ MachMgr::GetOperationNewName( string& sName) const
std::string
MachMgr::GetOperationName( int nId) const
{
// recupero il gruppo delle operazioni nella macchinata corrente
int nOperGrpId = GetCurrOperId() ;
if ( nOperGrpId == GDB_ID_NULL)
return "" ;
// recupero l'operazione
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGeomDB)) ;
if ( IsNull( pIter) || ! pIter->GoTo( nId))
return 0 ;
// verifico che il gruppo ricevuto sia corretto
if ( m_pGeomDB->GetParentId( nId) != nOperGrpId)
return "" ;
// recupero il nome del gruppo riferito
if ( pIter->GetParentId() != GetCurrOperId())
return 0 ;
// recupero il nome dell'operazione riferita
string sName ;
m_pGeomDB->GetName( nId, sName) ;
pIter->GetName( sName) ;
return sName ;
}
@@ -223,22 +254,18 @@ MachMgr::GetOperationId( const string& sName) const
// verifica dei parametri
if ( &sName == nullptr || sName.empty())
return false ;
// recupero il gruppo delle operazioni nella macchinata corrente
int nOperGrpId = GetCurrOperId() ;
if ( nOperGrpId == GDB_ID_NULL)
return GDB_ID_NULL ;
// recupero l'identificativo del gruppo con il nome indicato
// recupero l'identificativo dell'operazione con il nome indicato
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGeomDB)) ;
if ( IsNull( pIter))
return false ;
bool bIter = pIter->GoToFirstGroupInGroup( m_nMachBaseId) ;
while( bIter) {
bool bIter = pIter->GoToFirstInGroup( GetCurrOperId()) ;
while ( bIter) {
// verifico il nome
string sOperGrpName ;
if ( pIter->GetName( sOperGrpName) && EqualNoCase( sOperGrpName, sName))
string sOperName ;
if ( pIter->GetName( sOperName) && EqualNoCase( sOperName, sName))
return pIter->GetId() ;
// passo al successivo
bIter = pIter->GoToNextGroup() ;
bIter = pIter->GoToNext() ;
}
return GDB_ID_NULL ;
}
@@ -247,8 +274,9 @@ MachMgr::GetOperationId( const string& sName) const
bool
MachMgr::RemoveOperation( int nId)
{
// verifico sia una Operazione
if ( GetOperationType( nId) == OPER_NULL)
// verifico sia una Operazione diversa da Disposizione
int nType = GetOperationType( nId) ;
if ( nType == OPER_NULL || nType == OPER_DISP)
return false ;
// se lavorazione corrente, resetto
if ( m_nCurrMachiningId == nId)
@@ -260,15 +288,53 @@ MachMgr::RemoveOperation( int nId)
//----------------------------------------------------------------------------
bool
MachMgr::RemoveAllOperations( bool bExceptFirstDisp)
MachMgr::RemoveAllPhaseOperations( int nPhase)
{
// recupero la disposizione di inizio fase
int nDispId = GetPhaseDisposition( nPhase) ;
if ( nDispId == GDB_ID_NULL)
return true ;
// elimino tutte le operazioni successive della stessa fase
int nOperId = m_pGeomDB->GetNext( nDispId) ;
while ( nOperId != GDB_ID_NULL) {
int nNextOperId = m_pGeomDB->GetNext( nOperId) ;
if ( GetOperationPhase( nOperId) == nPhase) {
if ( m_nCurrMachiningId == nOperId)
m_nCurrMachiningId = GDB_ID_NULL ;
m_pGeomDB->Erase( nOperId) ;
}
else
break ;
nOperId = nNextOperId ;
}
return true ;
}
//----------------------------------------------------------------------------
bool
MachMgr::RemoveAllOperations( void)
{
// indice terminazione ciclo
int nStopId = ( bExceptFirstDisp ? GetFirstOperation() : GDB_ID_NULL) ;
int nStopId = GetFirstOperation() ;
// rimuovo tutte le operazioni a partire dalla fine
int nId = GetLastOperation() ;
while ( nId != GDB_ID_NULL && nId != nStopId) {
RemoveOperation( nId) ;
nId = GetLastOperation() ;
// se disposizione, elimino la fase
if ( GetOperationType( nId) == OPER_DISP)
RemoveLastPhase() ;
// altrimenti...
else {
// se lavorazione corrente, resetto
if ( m_nCurrMachiningId == nId)
m_nCurrMachiningId = GDB_ID_NULL ;
// eseguo la rimozione
m_pGeomDB->Erase( nId) ;
}
// recupero la nuova ultima (deve essere diversa dalla precedente)
int nPrevId = GetLastOperation() ;
if ( nPrevId == nId)
return false ;
nId = nPrevId ;
}
return true ;
}
@@ -357,6 +423,44 @@ MachMgr::SetAllOperationsStatus( bool bExceptFirstDisp, bool bShow)
return true ;
}
//----------------------------------------------------------------------------
bool
MachMgr::ChangeOperationPhase( int nId, int nNewPhase)
{
// l'operazione deve esistere e non essere una disposizione
int nType = GetOperationType( nId) ;
if ( nType == OPER_NULL || nType == OPER_DISP)
return false ;
// verifico che la nuova fase esista
if ( nNewPhase > m_nPhasesCount)
return false ;
// se la fase dell'operazione è già giusta, esco subito con successo
if ( GetOperationPhase( nId) == nNewPhase)
return true ;
// cerco l'ultima operazione della nuova fase
int nRefId = GDB_ID_NULL ;
int nCurrId = GetFirstOperation() ;
while ( nCurrId != GDB_ID_NULL) {
int nPhase = GetOperationPhase( nCurrId) ;
if ( nPhase == nNewPhase)
nRefId = nCurrId ;
else if ( nPhase > nNewPhase)
break ;
nCurrId = GetNextOperation( nCurrId) ;
}
if ( nRefId == GDB_ID_NULL)
return false ;
// recupero la lavorazione
Machining* pMch = GetMachining( m_pGeomDB->GetUserObj( nId)) ;
if ( pMch == nullptr)
return false ;
// sposto la lavorazione
if ( ! m_pGeomDB->Relocate( nId, nRefId, GDB_AFTER))
return false ;
// assegno nuova fase
return pMch->SetPhase( nNewPhase) ;
}
//----------------------------------------------------------------------------
// Dispositions
//----------------------------------------------------------------------------
@@ -371,14 +475,6 @@ MachMgr::AddDisposition( const string& sName)
string sNewName = sName ;
if ( ! GetOperationNewName( sNewName))
return GDB_ID_NULL ;
// eseguo
return AddDisposition( sNewName, nOperGrpId, m_nCurrPhase) ;
}
//----------------------------------------------------------------------------
int
MachMgr::AddDisposition( const string& sName, int nOperGrpId, int nPhase)
{
// inserisco il gruppo
int nId = m_pGeomDB->AddGroup( GDB_ID_NULL, nOperGrpId, GLOB_FRM) ;
if ( nId == GDB_ID_NULL)
@@ -391,10 +487,32 @@ MachMgr::AddDisposition( const string& sName, int nOperGrpId, int nPhase)
return GDB_ID_NULL ;
m_pGeomDB->SetUserObj( nId, pDisp) ;
pDisp->Init( this) ;
pDisp->SetPhase( nPhase) ;
pDisp->SetPhase( m_nCurrPhase) ;
return nId ;
}
//----------------------------------------------------------------------------
int
MachMgr::GetPhaseDisposition( int nPhase) const
{
// verifico esista la fase
if ( nPhase > m_nPhasesCount)
return GDB_ID_NULL ;
// cerco la disposizione nel gruppo delle operazioni
PtrOwner<IGdbIterator> pIter( CreateGdbIterator( m_pGeomDB)) ;
if ( IsNull( pIter))
return GDB_ID_NULL ;
bool bIter = pIter->GoToFirstInGroup( GetCurrOperId()) ;
while ( bIter) {
const Disposition* pDisp = ::GetDisposition( pIter->GetUserObj()) ;
if ( pDisp != nullptr && pDisp->GetPhase() == nPhase)
return pIter->GetId() ;
bIter = pIter->GoToNext() ;
}
return GDB_ID_NULL ;
}
//----------------------------------------------------------------------------
// Machinings
//----------------------------------------------------------------------------
@@ -418,6 +536,7 @@ MachMgr::SetCurrMachining( int nId)
m_nCurrMachiningId = nId ;
return true ;
}
//----------------------------------------------------------------------------
bool
MachMgr::ResetCurrMachining( void)
@@ -703,7 +822,7 @@ MachMgr::GetMachiningGeometry( SELVECTOR& vIds) const
//----------------------------------------------------------------------------
bool
MachMgr::IsEmpty( void) const
MachMgr::IsMachiningEmpty( void) const
{
// recupero la lavorazione corrente
int nCurrMchId = GetCurrMachining() ;