EgtMachKernel 1.6x8 :
- prima versione della gestione dell'attrezzaggio.
This commit is contained in:
Binary file not shown.
@@ -256,6 +256,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClCompile Include="SawingData.cpp" />
|
||||
<ClCompile Include="SawRoughing.cpp" />
|
||||
<ClCompile Include="SawRoughingData.cpp" />
|
||||
<ClCompile Include="SetupMgr.cpp" />
|
||||
<ClCompile Include="Simulator.cpp" />
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
@@ -307,6 +308,7 @@ copy $(TargetPath) \EgtProg\Dll64</Command>
|
||||
<ClInclude Include="SawRoughing.h" />
|
||||
<ClInclude Include="SawRoughingData.h" />
|
||||
<ClInclude Include="SetTempPhase.h" />
|
||||
<ClInclude Include="SetupMgr.h" />
|
||||
<ClInclude Include="Simulator.h" />
|
||||
<ClInclude Include="stdafx.h" />
|
||||
<ClInclude Include="Head.h" />
|
||||
|
||||
@@ -186,6 +186,9 @@
|
||||
<ClCompile Include="GenMachining.cpp">
|
||||
<Filter>Source Files\Operations</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SetupMgr.cpp">
|
||||
<Filter>Source Files\Tools</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="DllMain.h">
|
||||
@@ -320,6 +323,9 @@
|
||||
<ClInclude Include="GenMachining.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SetupMgr.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="EgtMachKernel.rc">
|
||||
|
||||
+107
-50
@@ -82,6 +82,10 @@ Generator::Run( const string& sCncFile, const std::string& sInfo)
|
||||
m_pMchMgr->GetCurrMachGroup() == GDB_ID_NULL)
|
||||
return false ;
|
||||
|
||||
// recupero eventuale attrezzaggio della macchinata
|
||||
m_stuMgr.Init( m_pMchMgr) ;
|
||||
m_stuMgr.Load() ;
|
||||
|
||||
// evento inizio esecuzione
|
||||
bool bOk = true ;
|
||||
if ( ! OnStart()) {
|
||||
@@ -90,7 +94,7 @@ Generator::Run( const string& sCncFile, const std::string& sInfo)
|
||||
}
|
||||
|
||||
// apertura file di output ed evento inizio programma
|
||||
if ( bOk && ! OnProgramStart( m_pMachine->GetMachineName(), sCncFile, sInfo)) {
|
||||
if ( bOk && ! OnProgramStart( m_pMachine->GetMachineName(), sCncFile, sInfo, m_stuMgr.Exists())) {
|
||||
bOk = false ;
|
||||
LOG_INFO( GetEMkLogger(), "OnProgramStart error") ;
|
||||
}
|
||||
@@ -167,7 +171,7 @@ Generator::ProcessDisposition( int nOpId, int nOpInd)
|
||||
// Se disposizione con movimenti macchina
|
||||
if ( ! pDisp->IsEmpty()) {
|
||||
// Recupero l'utensile della disposizione corrente
|
||||
string sTool ; string sHead ; int nExit ; string sTcPos ;
|
||||
string sTool ; string sHead ; int nExit ; string sTcPos ;
|
||||
if ( ! pDisp->GetToolData( sTool, sHead, nExit, sTcPos))
|
||||
return false ;
|
||||
// Se utensile cambierà
|
||||
@@ -270,15 +274,17 @@ Generator::ProcessMachining( int nOpId, int nOpInd)
|
||||
|
||||
// Se utensile cambierà
|
||||
if ( ! m_sTool.empty() && m_sTool != sTool) {
|
||||
// recupero la testa del prossimo utensile
|
||||
string sNextHead ; int nNextExit ; string sNextTcPos ;
|
||||
if ( m_pMchMgr->TdbSetCurrTool( sTool)) {
|
||||
m_pMchMgr->TdbGetCurrToolParam( TPA_HEAD, sNextHead) ;
|
||||
m_pMchMgr->TdbGetCurrToolParam( TPA_EXIT, nNextExit) ;
|
||||
m_pMchMgr->TdbGetCurrToolParam( TPA_TCPOS, sNextTcPos) ;
|
||||
// recupero la testa del prossimo utensile (prima dall'attrezzaggio, poi dal DB utensili)
|
||||
string sNextTcPos ; string sNextHead ; int nNextExit ;
|
||||
if ( ! m_stuMgr.GetToolData( sTool, sNextTcPos, sNextHead, nNextExit)) {
|
||||
if ( m_pMchMgr->TdbSetCurrTool( sTool)) {
|
||||
m_pMchMgr->TdbGetCurrToolParam( TPA_TCPOS, sNextTcPos) ;
|
||||
m_pMchMgr->TdbGetCurrToolParam( TPA_HEAD, sNextHead) ;
|
||||
m_pMchMgr->TdbGetCurrToolParam( TPA_EXIT, nNextExit) ;
|
||||
}
|
||||
// ripristino l'utensile corrente
|
||||
m_pMchMgr->TdbSetCurrTool( m_sTool) ;
|
||||
}
|
||||
// ripristino l'utensile corrente
|
||||
m_pMchMgr->TdbSetCurrTool( m_sTool) ;
|
||||
// emetto deselezione vecchio utensile
|
||||
if ( ! OnToolDeselect( sNextHead, nNextExit, sNextTcPos))
|
||||
return false ;
|
||||
@@ -288,9 +294,12 @@ Generator::ProcessMachining( int nOpId, int nOpInd)
|
||||
return false ;
|
||||
// Se utensile cambiato, emetto selezione nuovo utensile
|
||||
if ( m_sTool != m_sPrevTool) {
|
||||
string sHead ; m_pMchMgr->TdbGetCurrToolParam( TPA_HEAD, sHead) ;
|
||||
int nExit ; m_pMchMgr->TdbGetCurrToolParam( TPA_EXIT, nExit) ;
|
||||
string sTcPos ; m_pMchMgr->TdbGetCurrToolParam( TPA_TCPOS, sTcPos) ;
|
||||
string sTcPos ; string sHead ; int nExit ;
|
||||
if ( ! m_stuMgr.GetToolData( m_sTool, sTcPos, sHead, nExit)) {
|
||||
m_pMchMgr->TdbGetCurrToolParam( TPA_HEAD, sHead) ;
|
||||
m_pMchMgr->TdbGetCurrToolParam( TPA_EXIT, nExit) ;
|
||||
m_pMchMgr->TdbGetCurrToolParam( TPA_TCPOS, sTcPos) ;
|
||||
}
|
||||
if ( ! OnToolSelect( sTool, sHead, nExit, sTcPos))
|
||||
return false ;
|
||||
}
|
||||
@@ -434,9 +443,12 @@ Generator::UpdateTool( const string& sTool)
|
||||
// lo imposto come corrente
|
||||
if ( ! m_pMchMgr->TdbSetCurrTool( sTool))
|
||||
return false ;
|
||||
// lo carico in macchina
|
||||
string sHead ; m_pMchMgr->TdbGetCurrToolParam( TPA_HEAD, sHead) ;
|
||||
int nExit ; m_pMchMgr->TdbGetCurrToolParam( TPA_EXIT, nExit) ;
|
||||
// lo carico in macchina (se esiste attrezzaggio prendo i dati da questo)
|
||||
string sTcPos ; string sHead ; int nExit ;
|
||||
if ( ! m_stuMgr.GetToolData( m_sTool, sTcPos, sHead, nExit)) {
|
||||
m_pMchMgr->TdbGetCurrToolParam( TPA_HEAD, sHead) ;
|
||||
m_pMchMgr->TdbGetCurrToolParam( TPA_EXIT, nExit) ;
|
||||
}
|
||||
if ( ! m_pMchMgr->SetCalcTool( sTool, sHead, nExit))
|
||||
return false ;
|
||||
m_sTool = sTool ;
|
||||
@@ -506,7 +518,7 @@ Generator::OnEnd( void)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
Generator::OnProgramStart( const string& sMachName, const string& sCncFile, const string& sInfo)
|
||||
Generator::OnProgramStart( const string& sMachName, const string& sCncFile, const string& sInfo, bool bSetup)
|
||||
{
|
||||
// apro il file di output
|
||||
bool bOk = m_pMachine->WriterOpen( sCncFile) ;
|
||||
@@ -519,6 +531,8 @@ Generator::OnProgramStart( const string& sMachName, const string& sCncFile, cons
|
||||
// assegno info
|
||||
string sTxt = sInfo + " " + CurrDateTime() ;
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_INFO, sTxt) ;
|
||||
// assegno flag di presenza setup
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_SETUP, bSetup) ;
|
||||
// chiamo la funzione di inizio programma
|
||||
bOk = bOk && m_pMachine->LuaCallFunction( ON_PROGRAM_START) ;
|
||||
return bOk ;
|
||||
@@ -582,44 +596,87 @@ Generator::ProcessToolData( void)
|
||||
// passo alla operazione successiva
|
||||
nOpId = m_pMchMgr->GetNextActiveOperation( nOpId) ;
|
||||
}
|
||||
// ordino l'elenco degli utensili
|
||||
std::sort( vTdata.begin(), vTdata.end(), []( const MyToolData& a, const MyToolData& b)
|
||||
{ if ( a.sHead == b.sHead)
|
||||
return a.nExit < b.nExit ;
|
||||
else
|
||||
return a.sHead < b.sHead ; }) ;
|
||||
// emetto l'elenco degli utensili
|
||||
|
||||
bool bOk = true ;
|
||||
string sPrevHead ; int nPrevExit = 0 ; string sPrevTcPos ; string sPrevTool ;
|
||||
for ( size_t i = 0 ; i < vTdata.size() ; ++ i) {
|
||||
// se posizione diversa (testa o uscita o toolchanger)
|
||||
if ( vTdata[i].sHead != sPrevHead || vTdata[i].nExit != nPrevExit ||
|
||||
vTdata[i].sTcPos != sPrevTcPos) {
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TOOL, vTdata[i].sName) ;
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_HEAD, vTdata[i].sHead) ;
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_EXIT, vTdata[i].nExit) ;
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TCPOS, vTdata[i].sTcPos) ;
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TCOMP, vTdata[i].nComp) ;
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TDIAM, vTdata[i].dDiam) ;
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TLEN, vTdata[i].dLen) ;
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_SMAX, vTdata[i].dMaxSpeed) ;
|
||||
// se esiste, chiamo la funzione di emissione dati utensile
|
||||
if ( m_pMachine->LuaExistsFunction( ON_TOOL_DATA))
|
||||
bOk = bOk && m_pMachine->LuaCallFunction( ON_TOOL_DATA) ;
|
||||
// salvo dati correnti come precedenti
|
||||
sPrevHead = vTdata[i].sHead ;
|
||||
nPrevExit = vTdata[i].nExit ;
|
||||
sPrevTool = vTdata[i].sName ;
|
||||
sPrevTcPos = vTdata[i].sTcPos ;
|
||||
}
|
||||
// altrimenti
|
||||
else {
|
||||
if ( vTdata[i].sName != sPrevTool) {
|
||||
string sErr = "Error : two tools in same position : " + sPrevTool + "<->" + vTdata[i].sName ;
|
||||
|
||||
// se definito attrezzaggio
|
||||
if ( m_stuMgr.Exists()) {
|
||||
// verifico che tutti gli utensili siano attrezzati
|
||||
for ( size_t i = 0 ; i < vTdata.size() ; ++ i) {
|
||||
if ( ! m_stuMgr.FindTool( vTdata[i].sName)) {
|
||||
string sErr = "Error : " + vTdata[i].sName + " missing in setup " ;
|
||||
LOG_INFO( GetEMkLogger(), sErr.c_str())
|
||||
bOk = false ;
|
||||
}
|
||||
}
|
||||
// emetto l'elenco di tutti gli utensili attrezzati
|
||||
string sTcPos ; string sHead ; int nExit ; string sTool ;
|
||||
for ( int i = 1 ; m_stuMgr.GetPosData( i, sTcPos, sHead , nExit, sTool); ++ i) {
|
||||
// se nella posizione non c'è utensile, vado oltre
|
||||
if ( sTool.empty())
|
||||
continue ;
|
||||
// emetto i dati
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TOOL, sTool) ;
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_HEAD, sHead) ;
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_EXIT, nExit) ;
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TCPOS, sTcPos) ;
|
||||
if ( m_pMchMgr->TdbSetCurrTool( sTool)) {
|
||||
int nComp ; double dDiam ; double dLen ; double dMaxSpeed ;
|
||||
m_pMchMgr->TdbGetCurrToolParam( TPA_CORR, nComp) ;
|
||||
m_pMchMgr->TdbGetCurrToolParam( TPA_DIAM, dDiam) ;
|
||||
m_pMchMgr->TdbGetCurrToolParam( TPA_LEN, dLen) ;
|
||||
m_pMchMgr->TdbGetCurrToolParam( TPA_MAXSPEED, dMaxSpeed) ;
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TCOMP, nComp) ;
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TDIAM, dDiam) ;
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TLEN, dLen) ;
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_SMAX, dMaxSpeed) ;
|
||||
}
|
||||
// se esiste, chiamo la funzione di emissione dati utensile
|
||||
if ( m_pMachine->LuaExistsFunction( ON_TOOL_DATA))
|
||||
bOk = bOk && m_pMachine->LuaCallFunction( ON_TOOL_DATA) ;
|
||||
}
|
||||
}
|
||||
|
||||
// altrimenti emetto direttamente gli utensili
|
||||
else {
|
||||
// ordino l'elenco degli utensili
|
||||
std::sort( vTdata.begin(), vTdata.end(), []( const MyToolData& a, const MyToolData& b)
|
||||
{ if ( a.sHead == b.sHead)
|
||||
return a.nExit < b.nExit ;
|
||||
else
|
||||
return a.sHead < b.sHead ; }) ;
|
||||
// emetto l'elenco degli utensili
|
||||
string sPrevHead ; int nPrevExit = 0 ; string sPrevTcPos ; string sPrevTool ;
|
||||
for ( size_t i = 0 ; i < vTdata.size() ; ++ i) {
|
||||
// se posizione diversa (testa o uscita o toolchanger)
|
||||
if ( vTdata[i].sHead != sPrevHead || vTdata[i].nExit != nPrevExit ||
|
||||
vTdata[i].sTcPos != sPrevTcPos) {
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TOOL, vTdata[i].sName) ;
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_HEAD, vTdata[i].sHead) ;
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_EXIT, vTdata[i].nExit) ;
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TCPOS, vTdata[i].sTcPos) ;
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TCOMP, vTdata[i].nComp) ;
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TDIAM, vTdata[i].dDiam) ;
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_TLEN, vTdata[i].dLen) ;
|
||||
bOk = bOk && m_pMachine->LuaSetGlobVar( GLOB_VAR + GVAR_SMAX, vTdata[i].dMaxSpeed) ;
|
||||
// se esiste, chiamo la funzione di emissione dati utensile
|
||||
if ( m_pMachine->LuaExistsFunction( ON_TOOL_DATA))
|
||||
bOk = bOk && m_pMachine->LuaCallFunction( ON_TOOL_DATA) ;
|
||||
// salvo dati correnti come precedenti
|
||||
sPrevHead = vTdata[i].sHead ;
|
||||
nPrevExit = vTdata[i].nExit ;
|
||||
sPrevTool = vTdata[i].sName ;
|
||||
sPrevTcPos = vTdata[i].sTcPos ;
|
||||
}
|
||||
// altrimenti
|
||||
else {
|
||||
if ( vTdata[i].sName != sPrevTool) {
|
||||
string sErr = "Error : two tools in same position : " + sPrevTool + "<->" + vTdata[i].sName ;
|
||||
LOG_INFO( GetEMkLogger(), sErr.c_str())
|
||||
bOk = false ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bOk ;
|
||||
|
||||
+3
-1
@@ -14,6 +14,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "CamData.h"
|
||||
#include "SetupMgr.h"
|
||||
|
||||
class MachMgr ;
|
||||
class IGeomDB ;
|
||||
@@ -38,7 +39,7 @@ class Generator
|
||||
bool UpdateAxes( void) ;
|
||||
bool OnStart( void) ;
|
||||
bool OnEnd( void) ;
|
||||
bool OnProgramStart( const std::string& sMachName, const std::string& sCncFile, const std::string& sInfo) ;
|
||||
bool OnProgramStart( const std::string& sMachName, const std::string& sCncFile, const std::string& sInfo, bool bSetup) ;
|
||||
bool OnProgramEnd( void) ;
|
||||
bool ProcessToolData( void) ;
|
||||
bool OnToolSelect( const std::string& sTool, const std::string& sHead, int nExit, const std::string& sTcPos) ;
|
||||
@@ -66,6 +67,7 @@ class Generator
|
||||
MachMgr* m_pMchMgr ; // puntatore al gestore di tutte le lavorazioni
|
||||
IGeomDB* m_pGeomDB ; // puntatore al DB geometrico
|
||||
Machine* m_pMachine ; // puntatore alla macchina
|
||||
SetupMgr m_stuMgr ; // gestore dell'attrezzaggio
|
||||
std::string m_sPrevTool ; // nome dell'utensile precedente
|
||||
std::string m_sTool ; // nome dell'utensile corrente
|
||||
STRVECTOR m_AxesName ; // nomi degli assi macchina attivi
|
||||
|
||||
@@ -33,6 +33,7 @@ static const std::string GVAR_ST = ".St" ; // (string) token per
|
||||
static const std::string GVAR_MACHNAME = ".MACHNAME" ; // (string) nome macchina
|
||||
static const std::string GVAR_FILE = ".FILE" ; // (string) path file di output
|
||||
static const std::string GVAR_INFO = ".INFO" ; // (string) informazioni iniziali
|
||||
static const std::string GVAR_SETUP = ".SETUP" ; // (bool) flag definizione setup
|
||||
static const std::string GVAR_DISPID = ".DISPID" ; // (int) identificativo disposizione
|
||||
static const std::string GVAR_DISPIND = ".DISPIND" ; // (int) indice disposizione
|
||||
static const std::string GVAR_PHASE = ".PHASE" ; // (int) indice fase
|
||||
|
||||
+154
@@ -0,0 +1,154 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2017-2017
|
||||
//----------------------------------------------------------------------------
|
||||
// File : SetupMgr.cpp Data : 18.01.17 Versione : 1.6x8
|
||||
// Contenuto : Implementazione gestore attrezzaggio utensili.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 18.01.17 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//--------------------------- Include ----------------------------------------
|
||||
#include "stdafx.h"
|
||||
#include "SetupMgr.h"
|
||||
#include "DllMain.h"
|
||||
#include "MachMgr.h"
|
||||
|
||||
using namespace std ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
SetupMgr::SetupMgr( void)
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SetupMgr::Init( MachMgr* pMchMgr)
|
||||
{
|
||||
// verifico ambiente
|
||||
if ( pMchMgr == nullptr || pMchMgr->GetContextId() == 0 ||
|
||||
pMchMgr->GetGeomDB() == nullptr || pMchMgr->GetCurrMachine() == nullptr)
|
||||
return false ;
|
||||
m_pMchMgr = pMchMgr ;
|
||||
m_pGeomDB = m_pMchMgr->GetGeomDB() ;
|
||||
m_pMachine = m_pMchMgr->GetCurrMachine() ;
|
||||
// reset
|
||||
m_vStuData.clear() ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SetupMgr::Load( void)
|
||||
{
|
||||
// reset
|
||||
m_vStuData.clear() ;
|
||||
|
||||
// verifico ci sia una macchinata corrente
|
||||
if ( m_pMchMgr == nullptr || m_pGeomDB == nullptr || m_pMachine == nullptr ||
|
||||
m_pMchMgr->GetCurrMachGroup() == GDB_ID_NULL)
|
||||
return false ;
|
||||
|
||||
// recupero il gruppo di setup
|
||||
int nSetupId = m_pMchMgr->GetCurrSetupGroupId() ;
|
||||
|
||||
// eseguo la lettura dei campi di attrezzaggio
|
||||
int nPos = 1 ;
|
||||
while ( true) {
|
||||
// leggo una nuova posizione di attrezzaggio
|
||||
string sVal ;
|
||||
if ( ! m_pGeomDB->GetInfo( nSetupId, "Pos" + ToString( nPos), sVal))
|
||||
break ;
|
||||
// recupero i dati della posizione (Tn;Hm;1/Tuuid/Name,2/Tuuid/Name...)
|
||||
bool bAdded = false ;
|
||||
STRVECTOR vsTok1 ;
|
||||
Tokenize( sVal, ";", vsTok1) ;
|
||||
if ( vsTok1.empty())
|
||||
break ;
|
||||
SetupData stuData ;
|
||||
stuData.m_sTcPos = vsTok1[0] ;
|
||||
if ( vsTok1.size() >= 3) {
|
||||
stuData.m_sHead = vsTok1[1] ;
|
||||
STRVECTOR vsTok2 ;
|
||||
Tokenize( vsTok1[2], ",", vsTok2) ;
|
||||
for ( size_t i = 0 ; i < vsTok2.size() ; ++ i) {
|
||||
STRVECTOR vsTok3 ;
|
||||
Tokenize( vsTok2[i], "/", vsTok3) ;
|
||||
if ( vsTok3.size() >= 2) {
|
||||
if ( FromString( vsTok3[0], stuData.m_nExit) &&
|
||||
m_pMchMgr->TdbGetToolFromUUID( vsTok3[1], stuData.m_sName)) {
|
||||
bAdded = true ;
|
||||
m_vStuData.emplace_back( stuData) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( ! bAdded) {
|
||||
stuData.m_nExit = 0 ;
|
||||
m_vStuData.emplace_back( stuData) ;
|
||||
}
|
||||
// passo alla successiva posizione
|
||||
++ nPos ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SetupMgr::FindTool( const string& sName)
|
||||
{
|
||||
for ( size_t i = 0 ; i < m_vStuData.size() ; ++ i) {
|
||||
if ( EqualNoCase( sName, m_vStuData[i].m_sName))
|
||||
return true ;
|
||||
}
|
||||
return false ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SetupMgr::GetPosData( int nPos, string& sTcPos, string& sHead, int& nExit, string& sName)
|
||||
{
|
||||
// verifico che la posizione sia valida
|
||||
if ( nPos < 1 || nPos > int( m_vStuData.size()))
|
||||
return false ;
|
||||
// assegno i dati
|
||||
sTcPos = m_vStuData[nPos - 1].m_sTcPos ;
|
||||
if ( m_vStuData[nPos - 1].m_nExit > 0) {
|
||||
sHead = m_vStuData[nPos - 1].m_sHead ;
|
||||
nExit = m_vStuData[nPos - 1].m_nExit ;
|
||||
sName = m_vStuData[nPos - 1].m_sName ;
|
||||
}
|
||||
else {
|
||||
sHead = "" ;
|
||||
nExit = 0 ;
|
||||
sName = "" ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
SetupMgr::GetToolData( const string& sName, string& sTcPos, string& sHead, int& nExit, int* pnPos)
|
||||
{
|
||||
// cerco l'utensile
|
||||
int nI = - 1 ;
|
||||
for ( size_t i = 0 ; i < m_vStuData.size() ; ++ i) {
|
||||
if ( EqualNoCase( sName, m_vStuData[i].m_sName)) {
|
||||
nI = int( i) ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
if ( nI == -1)
|
||||
return false ;
|
||||
// assegno i dati
|
||||
sTcPos = m_vStuData[nI].m_sTcPos ;
|
||||
sHead = m_vStuData[nI].m_sHead ;
|
||||
nExit = m_vStuData[nI].m_nExit ;
|
||||
if ( pnPos != nullptr)
|
||||
*pnPos = nI + 1 ;
|
||||
return true ;
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
//----------------------------------------------------------------------------
|
||||
// EgalTech 2017-2017
|
||||
//----------------------------------------------------------------------------
|
||||
// File : SetupMgr.h Data : 18.01.17 Versione : 1.6x8
|
||||
// Contenuto : Dichiarazione della classe ToolsMgr.
|
||||
//
|
||||
//
|
||||
//
|
||||
// Modifiche : 18.01.17 DS Creazione modulo.
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class MachMgr ;
|
||||
class IGeomDB ;
|
||||
class Machine ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
struct SetupData
|
||||
{
|
||||
std::string m_sTcPos ; // posizione in macchina
|
||||
std::string m_sHead ; // testa macchina
|
||||
int m_nExit ; // uscita sulla testa
|
||||
std::string m_sName ; // nome dell'utensile attrezzato
|
||||
|
||||
SetupData( void) : m_nExit( 0) {}
|
||||
SetupData( const std::string& sTcPos, const std::string& sHead, int nExit, const std::string& sName)
|
||||
{ m_sTcPos = sTcPos ; m_sHead = sHead ; m_nExit = nExit ; m_sName = sName ;}
|
||||
} ;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
class SetupMgr
|
||||
{
|
||||
public :
|
||||
SetupMgr( void) ;
|
||||
bool Init( MachMgr* pMchMgr) ;
|
||||
bool Load( void) ;
|
||||
bool Save( void) const ;
|
||||
bool Exists( void)
|
||||
{ return ! m_vStuData.empty() ; }
|
||||
bool FindTool( const std::string& sName) ;
|
||||
bool GetPosData( int nPos, std::string& sTcPos, std::string& sHead, int& nExit, std::string& sName) ;
|
||||
bool GetToolData( const std::string& sName, std::string& sTcPos, std::string& sHead, int& nExit, int* pnPos = nullptr) ;
|
||||
|
||||
private :
|
||||
typedef std::vector< SetupData> STUDVECTOR ;
|
||||
|
||||
private :
|
||||
MachMgr* m_pMchMgr ; // puntatore al gestore di tutte le lavorazioni
|
||||
IGeomDB* m_pGeomDB ; // puntatore al DB geometrico
|
||||
Machine* m_pMachine ; // puntatore alla macchina
|
||||
STUDVECTOR m_vStuData ; // vettore dati di attrezzaggio
|
||||
} ;
|
||||
Reference in New Issue
Block a user