EgtMachKernel 2.1c4 :

- modifiche per gestire lo stato delle operazioni (ok, da ricalcolare, ....).
This commit is contained in:
Dario Sassi
2019-03-18 18:52:08 +00:00
parent 4c0ad599ed
commit 39bf1700d9
25 changed files with 1229 additions and 373 deletions
+75 -26
View File
@@ -92,6 +92,7 @@ Disposition::Clone( void) const
pDisp->m_sHead = m_sHead ;
pDisp->m_nExit = m_nExit ;
pDisp->m_sTcPos = m_sTcPos ;
pDisp->m_nStatus = m_nStatus ;
pDisp->m_nShifts = m_nShifts ;
pDisp->m_bSomeByHand = m_bSomeByHand ;
}
@@ -109,11 +110,11 @@ bool
Disposition::Dump( string& sOut, bool bMM, const char* szNewLine) const
{
sOut += GetClassName() + "[mm]" + szNewLine ;
sOut += "Tab=" + m_sTabName + ( m_bTabOk ? " (ok)" : " (to verify)") + szNewLine ;
sOut += "Phase=" + ToString( m_nPhase) + szNewLine ;
sOut += "Ref1=(" + ToString( m_ptRef1, 3) + ")" + szNewLine ;
sOut += "Area1=(" + ToString( m_b3Area1, 3) + ")" + szNewLine ;
sOut += "Area1Offs=" + ToString( m_dAreaOffset) + szNewLine ;
sOut += DIS_TABLE + EQUAL + m_sTabName + ( m_bTabOk ? " (ok)" : " (to verify)") + szNewLine ;
sOut += DIS_PHASE + EQUAL + ToString( m_nPhase) + szNewLine ;
sOut += DIS_REF1 + EQUAL + "(" + ToString( m_ptRef1, 3) + ")" + szNewLine ;
sOut += DIS_AREA1 + EQUAL + "(" + ToString( m_b3Area1, 3) + ")" + szNewLine ;
sOut += DIS_AREA1_OFFS + EQUAL + "(" + ToString( m_dAreaOffset) + szNewLine ;
for ( const auto& FixData : m_vFixData) {
sOut += "FxD=" + FixData.sName + "," +
ToString( FixData.nId) + ",(" +
@@ -138,11 +139,12 @@ Disposition::Dump( string& sOut, bool bMM, const char* szNewLine) const
break ;
}
}
sOut += "Num=" + ToString( m_nShifts) + szNewLine ;
sOut += "Head=" + m_sHead + szNewLine ;
sOut += "Exit=" + ToString( m_nExit) + szNewLine ;
sOut += "TcPos=" + m_sTcPos + szNewLine ;
sOut += "ByHand=" + ToString( m_bSomeByHand) + szNewLine ;
sOut += DIS_NUM + EQUAL + ToString( m_nShifts) + szNewLine ;
sOut += DIS_HEAD + EQUAL + m_sHead + szNewLine ;
sOut += DIS_EXIT + EQUAL + ToString( m_nExit) + szNewLine ;
sOut += DIS_TCPOS + EQUAL + m_sTcPos + szNewLine ;
sOut += DIS_SOMEBYHAND + EQUAL + ToString( m_bSomeByHand) + szNewLine ;
sOut += KEY_STAT + EQUAL + ToString( m_nStatus) + szNewLine ;
return true ;
}
@@ -156,7 +158,7 @@ Disposition::Save( int nBaseId, STRVECTOR& vString) const
int nFxdLines = 1 + 4 * nFxdTot ;
int nMvdTot = int( m_vMvrData.size()) ;
int nMvdLines = 1 + 4 * nMvdTot ;
int nOther = 6 ;
int nOther = 7 ;
vString.insert( vString.begin(), 4 + nFxdLines + nMvdLines + nOther, "") ;
// Nome
if ( ! SetVal( DIS_TABLE, m_sTabName, vString[++k]))
@@ -203,6 +205,8 @@ Disposition::Save( int nBaseId, STRVECTOR& vString) const
return false ;
if ( ! SetVal( DIS_AREA1_OFFS, m_dAreaOffset, vString[++k]))
return false ;
if ( ! SetVal( KEY_STAT, m_nStatus, vString[++k]))
return false ;
}
catch( ...) { return false ; }
return true ;
@@ -289,13 +293,17 @@ Disposition::Load( const STRVECTOR& vString, int nBaseGdbId)
if ( ! GetVal( vString[++k], DIS_AREA1_OFFS, m_dAreaOffset))
return false ;
}
if ( k + 1 < int( vString.size())) {
if ( ! GetVal( vString[++k], KEY_STAT, m_nStatus))
return false ;
}
return true ;
}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
Disposition::Disposition( void)
: m_bTabOk( false), m_nExit( 0), m_nShifts( 0), m_bSomeByHand( false), m_dAreaOffset({{0,0,0,0}})
: m_bTabOk( false), m_nExit( 0), m_nStatus( MCH_ST_TO_VERIFY), m_nShifts( 0), m_bSomeByHand( false), m_dAreaOffset({{0,0,0,0}})
{
}
@@ -594,8 +602,10 @@ Disposition::AddFixture( const string& sName, const Point3d& ptPos, double dAngD
}
}
// se da aggiungere alla lista
if ( bAddToList)
if ( bAddToList) {
m_vFixData.emplace_back( sName, nFixtId, ptPos, dAngDeg, dMov) ;
m_nStatus |= MCH_ST_GEO_MODIF ;
}
return nFixtId ;
}
@@ -668,6 +678,8 @@ Disposition::MoveFixture( int nId, const Vector3d& vtMove)
break ;
}
}
// imposto stato a modificato
m_nStatus |= MCH_ST_PARAM_MODIF ;
return true ;
}
@@ -690,6 +702,8 @@ Disposition::RotateFixture( int nId, double dDeltaAngDeg)
break ;
}
}
// imposto stato a modificato
m_nStatus |= MCH_ST_PARAM_MODIF ;
return true ;
}
@@ -720,6 +734,8 @@ Disposition::MoveFixtureMobile( int nId, double dDeltaMov)
break ;
}
}
// imposto stato a modificato
m_nStatus |= MCH_ST_PARAM_MODIF ;
return true ;
}
@@ -813,6 +829,8 @@ Disposition::RemoveFixture( int nId)
else
m_vFixData.erase( iIter) ;
}
// imposto stato a modificato
m_nStatus |= MCH_ST_GEO_MODIF ;
return true ;
}
@@ -859,8 +877,11 @@ Disposition::MoveToCornerRawPart( int nRawId, const Point3d& ptP, int nFlag, boo
if ( ! vtTotMove.IsSmall())
m_pGeomDB->TranslateGlob( nRawId, vtTotMove) ;
// se da aggiungere alla lista
if ( bAddToList)
if ( bAddToList) {
InsertMoveInfoInList( nRawId, MoveRawData::COR, ptP, nFlag) ;
// imposto stato a modificato
m_nStatus |= MCH_ST_PARAM_MODIF ;
}
return true ;
}
@@ -913,8 +934,11 @@ Disposition::MoveToCenterRawPart( int nRawId, const Point3d& ptP, int nFlag, boo
if ( ! vtTotMove.IsSmall())
m_pGeomDB->TranslateGlob( nRawId, vtTotMove) ;
// se da aggiungere alla lista
if ( bAddToList)
if ( bAddToList) {
InsertMoveInfoInList( nRawId, MoveRawData::CEN, ptP, nFlag) ;
// imposto stato a modificato
m_nStatus |= MCH_ST_PARAM_MODIF ;
}
return true ;
}
@@ -955,6 +979,8 @@ Disposition::MoveRawPart( int nRawId, const Vector3d& vtMove)
m_pGeomDB->TranslateGlob( nRawId, vtMove) ;
// aggiorno comando di movimento
rTras->ptP += vtMove ;
// imposto stato a modificato
m_nStatus |= MCH_ST_PARAM_MODIF ;
return true ;
}
@@ -1055,6 +1081,8 @@ Disposition::RotateRawPart( int nRawId, const Vector3d& vtAx, double dAngRotDeg)
// aggiungo o modifico nella lista
InsertMoveInfoInList( nRawId, MoveRawData::ROT, Point3d( dAngCDeg, dAngADeg, dAngC1Deg), 0) ;
}
// imposto stato a modificato
m_nStatus |= MCH_ST_PARAM_MODIF ;
return true ;
}
@@ -1084,6 +1112,8 @@ Disposition::ApplyRotationToRawPart( int nRawId, double dAngCDeg, double dAngADe
if ( bAddToList) {
// non ci sono problemi di compensazione della traslazione perchè già processata precedentemente in RotateRawPart
InsertMoveInfoInList( nRawId, MoveRawData::ROT, Point3d( dAngCDeg, dAngADeg, dAngC1Deg), 0) ;
// imposto stato a modificato
m_nStatus |= MCH_ST_PARAM_MODIF ;
}
return true ;
}
@@ -1163,6 +1193,8 @@ Disposition::RemoveRawPart( int nRawId)
else
m_vMvrData.erase( iIter) ;
}
// imposto stato a modificato
m_nStatus |= MCH_ST_GEO_MODIF ;
return true ;
}
@@ -1211,6 +1243,7 @@ Disposition::SpecialApply( bool bRecalc)
// reset
m_sHead.clear() ;
m_nExit = 0 ;
int nCurrShifts = m_nShifts ;
m_nShifts = 0 ;
m_bSomeByHand = false ;
m_sTcPos.clear() ;
@@ -1219,6 +1252,26 @@ Disposition::SpecialApply( bool bRecalc)
if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr)
return false ;
// recupero la macchina corrente
Machine* pMch = m_pMchMgr->GetCurrMachine() ;
if ( pMch == nullptr)
return false ;
// se non esiste la funzione, non devo fare alcunché
static const string ON_SPECIAL_APPLY = "OnSpecialApplyDisposition" ;
if ( ! pMch->LuaExistsFunction( ON_SPECIAL_APPLY)) {
m_nStatus = MCH_ST_OK ;
return true ;
}
// verifico se necessario continuare nell'aggiornamento
if ( ! bRecalc && m_nStatus == MCH_ST_OK) {
m_nShifts = nCurrShifts ;
LOG_INFO( GetEMkLogger(), "Disposition postapply skipped : status already ok") ;
return true ;
}
m_nStatus = MCH_ST_TO_VERIFY ;
// costanti
static const string EMC_VAR = "EMC" ; // tabella variabili locali per calcolo
static const string EVAR_TABNAME = ".TABNAME" ; // IN (string) nome della tavola macchina
@@ -1230,16 +1283,6 @@ Disposition::SpecialApply( bool bRecalc)
static const string EVAR_TCPOS = ".TCPOS" ; // OUT (string) nome della posizione nel TC
static const string EVAR_SHIFTS = ".SHIFTS" ; // OUT (int) numero di movimenti eseguiti
static const string EVAR_SBH = ".SBH" ; // OUT (bool) flag presenza operazioni manuali
static const string ON_SPECIAL_APPLY = "OnSpecialApplyDisposition" ;
// recupero la macchina corrente
Machine* pMch = m_pMchMgr->GetCurrMachine() ;
if ( pMch == nullptr)
return false ;
// se non esiste la funzione, non devo fare alcunché
if ( ! pMch->LuaExistsFunction( ON_SPECIAL_APPLY))
return true ;
// eseguo l'azione
bool bOk = true ;
@@ -1273,7 +1316,13 @@ Disposition::SpecialApply( bool bRecalc)
}
// eseguo aggiornamento assi macchina e collegamento con operazione precedente
return SpecialUpdate() ;
if ( ! SpecialUpdate())
return false ;
// aggiorno stato
m_nStatus = MCH_ST_OK ;
return true ;
}
//----------------------------------------------------------------------------