Files
Dario Sassi 932700d4b2 EgtMachKernel :
- corretta AddRobotClimb (aggiungeva entità in posizione non corretta)
- aggiunta gestione soluzione indeterminata con tre assi rotanti liberi.
2026-04-09 20:17:50 +02:00

464 lines
28 KiB
C++

//----------------------------------------------------------------------------
// EgalTech 2015-2023
//----------------------------------------------------------------------------
// File : Machine.h Data : 16.01.23 Versione : 2.5a2
// Contenuto : Dichiarazione della classe Machine.
//
//
//
// Modifiche : 06.05.15 DS Creazione modulo.
//
//
//----------------------------------------------------------------------------
#pragma once
#include "MachineStruConst.h"
#include "/EgtDev/Include/EXeExecutor.h"
#include "/EgtDev/Include/EGkGeomDB.h"
#include "/EgtDev/Include/EGkLuaAux.h"
#include "/EgtDev/Include/EGnLuaMgr.h"
#include "/EgtDev/Include/EGnWriter.h"
#include <unordered_map>
class MachMgr ;
class Axis ;
class Table ;
class Head ;
class TcPos ;
class Exit ;
//----------------------------------------------------------------------------
class Machine
{
public :
Machine( void) ;
~Machine( void) ;
bool Init( const std::string& sMachineName, const std::string& sMachineDir, MachMgr* pMchMgr) ;
const std::string& GetMachineName( void) const
{ return m_sName ; }
const std::string& GetMachineDir( void) const
{ return m_sMachineDir ; }
int GetMachineId( void) const
{ return m_nGroupId ; }
int GetBaseId( const std::string& sBase) const
{ int nId = GetGroup( sBase) ;
return ( IsBaseGroup( nId) ? nId : GDB_ID_NULL) ; }
int GetTableId( const std::string& sTable) const
{ int nId = GetGroup( sTable) ;
return ( IsTableGroup( nId) ? nId : GDB_ID_NULL) ; }
int GetAxisId( const std::string& sAxis) const
{ int nId = GetGroup( sAxis) ;
return ( IsAxisGroup( nId) ? nId : GDB_ID_NULL) ; }
bool GetAxisName( int nAxId, std::string& sAxis) const ;
int GetHeadId( const std::string& sHead) const
{ int nId = GetGroup( sHead) ;
return ( IsHeadGroup( nId) ? nId : GDB_ID_NULL) ; }
int GetExitId( const std::string& sHead, int nExit) const
{ int nHeadId = GetHeadId( sHead) ;
int nId = ( m_pGeomDB != nullptr ? m_pGeomDB->GetFirstNameInGroup( nHeadId, MCH_EXIT + ToString( nExit)) : GDB_ID_NULL) ;
return ( IsExitGroup( nId) ? nId : GDB_ID_NULL) ; }
int GetTcPosId( const std::string& sTcPos) const
{ int nId = GetGroup( sTcPos) ;
return ( IsTcPosGroup( nId) ? nId : GDB_ID_NULL) ; }
bool IsBaseGroup( int nGroup) const ;
bool IsAxisGroup( int nGroup) const
{ return ( GetAxis( nGroup) != nullptr) ; }
bool IsLinearAxisGroup( int nGroup) const ;
bool IsRotaryAxisGroup( int nGroup) const ;
bool IsTableGroup( int nGroup) const
{ return ( GetTable( nGroup) != nullptr) ; }
bool IsHeadGroup( int nGroup) const
{ return ( GetHead( nGroup) != nullptr) ; }
bool IsTcPosGroup( int nGroup) const
{ return ( GetTcPos( nGroup) != nullptr) ; }
bool IsExitGroup( int nGroup) const
{ return ( GetExit( nGroup) != nullptr) ; }
bool GetAllAxesIds( INTVECTOR& vIds) const ;
bool GetAllTablesNames( STRVECTOR& vNames) const ;
bool GetAllAxesNames( STRVECTOR& vNames) const ;
bool GetAllHeadsNames( STRVECTOR& vNames) const ;
bool GetAllTcPosNames( STRVECTOR& vNames) const ;
int GetFirstTable( void) const ;
int GetHeadExitCount( const std::string& sHead) const ;
int GetHeadExitPosDirAux( const std::string& sHead, int nExit, Point3d& ptPos, Vector3d& vtDir, Vector3d& vtAux) const ;
int GetHeadSolCh( const std::string& sHead) const ;
int GetHeadSelectType(const std::string& sHead) const ;
double GetAngDeltaMinForHome( void) const
{ return m_dAngDeltaMinForHome ; }
bool GetMultiProcess( int nOpt = 1) const
{ return ( m_nMultiProcess >= nOpt) ; }
int GetLinkAxesMoveOrder( void) const
{ return m_nLinkAxesMoveOrder ; }
bool GetNewLinkMgr( int nOpt = 1) const
{ return ( m_nNewLinkMgr >= nOpt || m_nCalcChainType == KIN_CHAIN_ROBOT) ; }
bool LoadTool( const std::string& sHead, int nExit, const std::string& sTool) ;
bool GetLoadedTool( const std::string& sHead, int nExit, std::string& sTool) const ;
bool UnloadTool( const std::string& sHead, int nExit) ;
bool LoadTools( const std::string& sHead, int nNoExit, int* pnCount = nullptr) ;
bool UnloadTools( const std::string& sHead) ;
bool LoadAllTools( void) ;
bool UnloadAllTools( void) ;
bool ResetHeadSet( const std::string& sHead) ;
const STRVECTOR& GetHSet( const std::string& sHead) const ;
bool GetAxisToken( const std::string& sAxis, std::string& sToken) const ;
bool GetAxisInvert( const std::string& sAxis, bool& bInvert) const ;
bool GetAxisOffset( const std::string& sAxis, double& dOffset) const ;
bool GetAxisType( const std::string& sAxis, bool& bLinear) const ;
bool GetAxisDir( const std::string& sAxis, Vector3d& vtDir) const ;
bool SetAxisPos( const std::string& sAxis, double dVal, bool bInStroke = true, double* pdNewVal = nullptr) ;
bool GetAxisPos( const std::string& sAxis, double& dVal) const ;
bool GetAxisMin( const std::string& sAxis, double& dMin) const ;
bool GetAxisMax( const std::string& sAxis, double& dMax) const ;
bool GetAxisHomePos( const std::string& sAxis, double& dHomeVal) const ;
bool IsDispositionAxis( int nAxisId, int nTableId = GDB_ID_NULL) const ;
bool IsDispositionAxis( const std::string& sAxis, const std::string& sTable = "") const ;
bool ResetAxisPos( const std::string& sAxis) ;
bool ResetAllAxesPos( bool bStdAxes, bool bDispAxes) ;
bool SetCurrTable( const std::string& sTable) ;
bool ResetCurrTable( void) ;
int GetCurrTable( void) const ;
bool GetCurrTable( std::string& sTable) const ;
bool GetCurrTableRef1( Point3d& ptRef1) const ;
bool GetCurrTableArea1( BBox3d& b3Area1) const ;
bool GetCurrTableDeltaRef1( Vector3d& vtDelta1) const ;
bool GetCurrTableIsTilting( bool& bTilting, Vector3d& vtTiltingAx) const ;
bool GetCurrTableCollGroups( INTVECTOR& vIds) const ;
bool SetCurrTool( const std::string& sTool, const std::string& sHead, int nExit) ;
bool ResetCurrTool( void) ;
int GetCurrTool( void) const ;
bool GetCurrTool( std::string& sTool) const ;
int GetCurrHead( void) const ;
bool GetCurrHead( std::string& sHead) const ;
int GetCurrExit( void) const ;
bool GetCurrExit( int& nExit) const ;
bool GetCurrHeadCollGroups( INTVECTOR& vIds) const ;
bool IsCurrToolFloating( void) const ;
double GetCurrRot1W( void) const
{ return m_dCalcRot1W ; }
bool SetSingConeAng( double dAng)
{ m_dSingConeAng = dAng ; return true ;}
double GetCurrSingConeAng( void) const
{ return m_dSingConeAng ; }
bool GetCurrCalcMaxDeltaR2OnFirst( void) const
{ return m_bCalcMaxDeltaR2On1 ; }
std::string GetKinematicAxis( int nInd) const ;
bool BlockKinematicRotAxis( const std::string& sName, double dVal) ;
bool BlockKinematicRotAxis( int nId, double dVal) ;
bool FreeKinematicRotAxis( const std::string& sName) ;
bool FreeKinematicRotAxis( int nId) ;
bool IsKinematicRotAxisBlocked( int nInd) const ;
bool GetKinematicRotAxisBlocked( int nInd, std::string& sName, double& dVal) const ;
bool SetSolCh( int nScc, bool bExact) ;
bool GetSolCh( int& nScc, bool& bExact)
{ nScc = m_nCalcSolCh ; bExact = m_bSolChExact ; return true ; }
int GetCurrLinAxes( void) const ;
int GetCurrRotAxes( void) const ;
bool GetCurrAxisName( int nInd, std::string& sAxName) const ;
bool GetAllCurrAxesNames( STRVECTOR& vAxName) const ;
bool GetCurrAxisToken( int nInd, std::string& sAxToken) const ;
bool GetAllCurrAxesTokens( STRVECTOR& vAxToken) const ;
bool GetCurrAxisType( int nInd, bool& bLinear, bool& bHead) const ;
bool GetCurrAxisMin( int nInd, double& dMin) const ;
bool GetCurrAxisMax( int nInd, double& dMax) const ;
bool GetCurrAxisOffset( int nInd, double& dOffset) const ;
bool GetCurrAxisInvert( int nInd, bool& bInvert) const ;
bool GetCurrAxisHomePos( int nInd, double& dHome) const ;
bool GetAllCurrAxesHomePos( DBLVECTOR& vAxHomeVal) const ;
const Frame3d& GetCurrLinAxesFrame( void) const
{ return m_frLinAx ; }
int GetCurrKinematicChainType( void) const
{ return m_nCalcChainType ; }
bool SetPrevAngA( double dAngA) const
{ m_dPrevAngA = dAngA ; return true ; }
bool GetAngles( const Vector3d& vtDirT, const Vector3d& vtDirA,
int& nStat, DBLVECTOR& vAng1, DBLVECTOR& vAng2) const ;
bool GetPositions( const Point3d& ptP, const DBLVECTOR& vAng,
double& dX, double& dY, double& dZ) const ;
bool GetRobotAngles( const Point3d& ptP, const Vector3d& vtDirT, const Vector3d& vtDirA,
DBLVECTOR& vAng1, DBLVECTOR& vAng2) const ;
bool GetNoseFromPositions( double dX, double dY, double dZ, const DBLVECTOR& vAng,
Point3d& ptNose) const ;
bool GetTipFromPositions( double dX, double dY, double dZ, const DBLVECTOR& vAng,
bool bOverall, bool bBottom, bool bBack, Point3d& ptTip) const ;
bool GetToolDirFromAngles( const DBLVECTOR& vAng, Vector3d& vtDir) const ;
bool GetAuxDirFromAngles( const DBLVECTOR& vAng, Vector3d& vtDir) const ;
bool GetPartDirFromAngles( const Vector3d& vtPart, const DBLVECTOR& vAng, Vector3d& vtDir) const ;
bool GetBackToolDirFromAngles( const DBLVECTOR& vAng, Vector3d& vtDir) const ;
bool GetBackAuxDirFromAngles( const DBLVECTOR& vAng, Vector3d& vtDir) const ;
bool GetNearestAngleInStroke( int nInd, double dAngRef, double& dAng) const ;
bool LimitAngleToStroke( int nInd, double& dAng) const ;
bool VerifyAngleOutstroke( int nInd, double dAng) const ;
bool VerifyOutstroke( double dX, double dY, double dZ, const DBLVECTOR& vAng, bool bClear, int& nStat) const ;
bool ExistProtectedAreas( void) const ;
bool VerifyProtectedAreas( double dX, double dY, double dZ, const DBLVECTOR& vAng, int& nStat) ;
bool VerifyOutstroke( const std::string& sAxName, double dVal) const ;
std::string GetOutstrokeInfo( bool bMM = true) const ;
void ResetOutstrokeInfo( void) const
{ m_OutstrokeInfo.Clear() ; }
bool SetLook( int nFlag) ;
int GetLook( void) const
{ return m_nMachineLook ; }
bool LinkRawPartToGroup( int nRawPartId, const std::string& sGroupName) ;
bool IsLinkedRawPart( int nRawId) const ;
const INTVECTOR& GetAllLinkedRawParts( void) const ;
bool UnlinkRawPartFromGroup( int nRawPartId) ;
bool UnlinkAllRawPartsFromGroups( void) ;
bool LinkFixtureToGroup( int nFxtId, const std::string& sGroupName) ;
bool IsLinkedFixture( int nFxtId) const ;
bool UnlinkFixtureFromGroup( int nFxtId) ;
bool UnlinkAllFixturesFromGroups( void) ;
bool LinkPartToGroup( int nPartId, const std::string& sGroupName) ;
bool IsLinkedPart( int nPartId) const ;
bool UnlinkPartFromGroup( int nPartId) ;
bool UnlinkAllPartsFromGroups( void) ;
bool LuaExistsFunction( const std::string& sFun) const ;
bool LuaCallFunction( const std::string& sFun, bool bSetModifiedOff = true) ;
bool LuaCreateGlobTable( const std::string& sName) ;
bool LuaResetGlobVar( const std::string& sName) ;
bool LuaChangeNameGlobVar( const std::string& sOldName, const std::string& sNewName) ;
template <typename T>
bool LuaSetGlobVar( const std::string& sVar, const T& Val) ;
template <typename T>
bool LuaGetGlobVar( const std::string& sVar, T& Val) ;
bool WriterOpen( const std::string& sOutFile) ;
bool WriterClose( void) ;
bool WriterEmit( const std::string& sLine) ;
private :
void Clear( void) ;
bool LoadMachineGeometry( const std::string& sMGeoName, const Vector3d& vtOffset) ;
bool LoadMachineBase( const std::string& sName, const std::string& sGeo, const STRVECTOR& vsAux) ;
bool AdjustAuxGeometry( const STRVECTOR& vsAux, int nLay) ;
bool LoadMachineTable( const std::string& sName, const std::string& sParent, int nType,
const Point3d& ptRef1, double dCoeffX, double dCoeffY, double dCoeffZ,
const STRVECTOR& vsColl, const std::string& sGeo, const STRVECTOR& vsAux) ;
bool AdjustTable( int nLay, const Point3d& ptRef1) ;
bool LoadMachineAxis( const std::string& sName, const std::string& sParent, const std::string& sToken, bool bInvert,
double dOffset, int nType, int nUse, const Point3d& ptPos, const Vector3d& vtDir,
const STROKE& Stroke, double dHome, bool bAdjustAux, const std::string& sGeo, const STRVECTOR& vsAux) ;
bool AdjustAxis( int nLay, const std::string& sPart, const std::string& sName,
int nType, const Point3d& ptPos, const Vector3d& vtDir, bool bAdjustAux) ;
bool ModifyMachineAxisPosition( const std::string& sName, const Point3d& ptPos) ;
bool ModifyMachineAxisDirection( const std::string& sName, const Vector3d& vtDir) ;
bool ModifyMachineAxisStroke( const std::string& sName, const STROKE& Stroke) ;
bool ModifyMachineAxisHome( const std::string& sName, double dHome) ;
bool LoadMachineStdHead( const std::string& sName, const std::string& sParent, const std::string& sHSet,
const Point3d& ptPos, const Vector3d& vtTDir, const Vector3d& vtADir,
double dRot1W, bool bMaxDeltaR2On1, const STROKE& Rot2Stroke, int nSolCh, const STRVECTOR& vsOthColl,
const std::string& sGeo, const STRVECTOR& vsAux) ;
bool LoadMachineMultiHead( const std::string& sName, const std::string& sParent, const std::string& sHSet,
int nSelectType, const MUEXITVECTOR& vMuExit, const Vector3d& vtADir,
double dRot1W, bool bMaxDeltaR2On1, const STROKE& Rot2Stroke, int nSolCh, const STRVECTOR& vsOthColl,
const std::string& sGeo, const STRVECTOR& vsAux) ;
bool LoadMachineSpecialHead( const std::string& sName, const std::string& sParent, const std::string& sHSet,
const Point3d& ptPos, const Vector3d& vtTDir, const Vector3d& vtADir,
double dRot1W, bool bMaxDeltaR2On1, const STROKE& Rot2Stroke, int nSolCh, const STRVECTOR& vsOthColl,
const std::string& sGeo, const STRVECTOR& vsAux) ;
bool LoadMachineStdTcPos( const std::string& sName, const std::string& sParent,
const Point3d& ptPos, const Vector3d& vtTDir, const Vector3d& vtADir,
const std::string& sGeo, const STRVECTOR& vsAux) ;
bool LoadMachineMultiTcPos( const std::string& sName, const std::string& sParent,
const MUEXITVECTOR& vMuExit, const Vector3d& vtADir,
const std::string& sGeo, const STRVECTOR& vsAux) ;
int GetGroup( const std::string& sGroup) const ;
Axis* GetAxis( int nGroup) const ;
Table* GetTable( int nGroup) const ;
Head* GetHead( int nGroup) const ;
TcPos* GetTcPos( int nGroup) const ;
Exit* GetExit( int nGroup) const ;
bool AddHeadToSet( const std::string& sHSet, const std::string& sName) ;
bool EnableHeadInSet( const std::string& sHead) ;
bool LoadTool( Exit* pExit, const std::string& sTool) ;
bool ModifyMachineHeadAuxDirection( const std::string& sHead, const Vector3d& vtADir) ;
bool AdjustExitFrames( int nLay, const MUEXITVECTOR& vMuExit, const Vector3d& vtADir) ;
bool CreateExitGroups( int nLay, const MUEXITVECTOR& vMuExit) ;
bool ModifyMachineExitPosition( const std::string& sHead, int nExit, const Point3d& ptPos) ;
bool ClearKinematicChain( void) ;
bool CalculateKinematicChain( void) ;
bool AddKinematicAxis( bool bOnHead, int nId) ;
bool GetMyAngles( const Vector3d& vtDirT, const Vector3d& vtDirA,
const Vector3d& vtDirH, const Vector3d& vtDirI,
int nNumRotAx, const KinAxis& RotAx1, const KinAxis& RotAx2,
int& nStat, double& dAngA1, double& dAngB1, double& dAngA2, double& dAngB2) const ;
bool GetMyAngles( const Vector3d& vtDirT, const Vector3d& vtDirA,
const Vector3d& vtDirH, const Vector3d& vtDirI,
const KinAxis& RotAx1, const KinAxis& RotAx2, const KinAxis& RotAx3,
int& nStat, double& dAngA1, double& dAngB1, double& dAngC1, double& dAngA2, double& dAngB2, double& dAngC2) const ;
bool GetDirection( const Vector3d& vtDir, const DBLVECTOR& vAng, Vector3d& vtNew) const ;
bool GetBackDirection( const Vector3d& vtDir, const DBLVECTOR& vAng, Vector3d& vtNew) const ;
bool GetSccDir( int nSolCh, const Vector3d& vtDirA, Vector3d& vtDirScc) const ;
bool VerifyScc( const Vector3d& vtDirI, const Vector3d& vtDirA, int nSolCh, bool bExact) const ;
bool AdjustAngleInStroke( const STROKE& Stroke, double& dAng) const ;
bool LuaInit( const std::string& sMachineName) ;
bool LuaExit( void) ;
bool LuaLoadMachine( const std::string& sFile) ;
private :
typedef std::unordered_map< std::string, int> STRINT_UMAP ;
private :
// generali
MachMgr* m_pMchMgr ; // puntatore al gestore di tutte le lavorazioni
IGeomDB* m_pGeomDB ; // puntatore al DB geometrico
int m_nContextId ; // indice contesto corrente (1-based)
LuaMgr m_LuaMgr ; // interprete lua della macchina
Writer m_Writer ; // scrittore di file di testo
// dati macchina
std::string m_sName ; // nome della macchina
std::string m_sMachineDir ; // direttorio della macchina
int m_nGroupId ; // Id del gruppo della macchina
int m_nTempGroupId ; // Id del gruppo temporaneo macchina per carico
STRINT_UMAP m_mapGroups ; // dizionario dei gruppi della macchina
double m_dAxisMaxAdjust ; // massimo aggiustamento asse da geometria a descrizione cinematica
double m_dAxisMaxRotAdj ; // massima rotazione di aggiustamento asse da geometria a descrizione cinematica
double m_dExitMaxAdjust ; // massimo aggiustamento uscita da geometria a descrizione cinematica
double m_dExitMaxRotAdj ; // massima rotazione di aggiustamento uscita da geometria a descrizione cinematica
double m_dAngDeltaMinForHome ; // minima differenza angolare da valore precedente per scegliere di stare vicino a home
int m_nMultiProcess ; // codice di macchina multi-processo (con stima speciale e simulazione ad hoc)
int m_nLinkAxesMoveOrder ; // codice ordine interpolazione assi nei collegamenti (0=interpolati, ...)
int m_nNewLinkMgr ; // codice del nuovo gestore link tra lavorazioni (0=vecchio, 1=nuovo)
INTVECTOR m_vLinkedRawParts ; // elenco dei grezzi agganciati a gruppi della macchina
INTVECTOR m_vLinkedFixtures ; // elenco dei bloccaggi agganciati a gruppi della macchina
INTVECTOR m_vLinkedParts ; // elenco dei pezzi agganciati a gruppi della macchina
// dati di calcolo
int m_nCalcTabId ; // tavola corrente per calcoli
int m_nCalcHeadId ; // testa corrente per calcoli
int m_nCalcExitId ; // uscita corrente per calcoli
int m_nCalcToolId ; // utensile corrente per calcoli
double m_dCalcRot1W ; // peso del primo asse rotante per i confronti
double m_dSingConeAng ; // angolo di apertura del cono di direzioni considerate coincidenti con asse singolare
bool m_bCalcMaxDeltaR2On1 ; // flag utilizzo controllo massimo delta secondo asse rotante su inizio lavorazione
int m_nCalcSolCh ; // criterio di scelta della soluzione
bool m_bSolChExact ; // flag per scelta soluzione da soddisfare esattamente
Point3d m_ptCalcPos ; // posizione utensile a riposo per calcoli
Vector3d m_vtCalcDir ; // direzione utensile a riposo per calcoli
Vector3d m_vtCalcADir ; // direzione ausiliaria a riposo per calcoli
double m_dCalcTLen ; // lunghezza utensile corrente per calcoli
double m_dCalcTRad ; // raggio utensile corrente per calcoli
double m_dCalcTOvLen ; // lunghezza di ingombro utensile corrente per calcoli
double m_dCalcTOvRad ; // raggio di ingombro utensile corrente per calcoli
int m_nTabLinAxes ; // numero assi lineari attivi di tavola per calcoli
int m_nTabRotAxes ; // numero assi rotanti attivi di tavola per calcoli
int m_nHeadLinAxes ; // numero assi lineari attivi di testa per calcoli
int m_nHeadRotAxes ; // numero assi rotanti attivi di testa per calcoli
int m_nHeadSpecRotAxis ; // indice eventuale asse rotante speciale di testa prima dei lineari di testa (-1 non esiste)
KINAXISVECTOR m_vCalcLinAx ; // vettore assi lineari attivi per calcoli
KINAXISVECTOR m_vCalcRotAx ; // vettore assi rotanti attivi per calcoli
Frame3d m_frLinAx ; // sistema di riferimento definito dagli assi lineari
Frame3d m_frRobot ; // sistema di riferimento canonico del robot
int m_nCalcChainType ; // tipologia testa attiva (nulla, centro di lavoro o robot)
Point3d m_ptWristCen ; // centro del polso sferico nel riferimento testa/uscita di calcolo
Vector3d m_vtWristRef ; // direzione del polso sferico nel riferimento testa/uscita di calcolo
mutable double m_dPrevAngA ; // angolo precedente di riferimento per soluzione indeterminata
mutable OutStroke m_OutstrokeInfo ; // informazioni su ultima extra corsa
// stato di visualizzazione
int m_nMachineLook ; // stato di visualizzazione della macchina
// Static per interprete Lua di macchina
private :
static Machine* m_pMchLua ;
private :
static int LuaEmtGeneral( lua_State* L) ;
static int LuaEmtBase( lua_State* L) ;
static int LuaEmtTable( lua_State* L) ;
static int LuaEmtAxis( lua_State* L) ;
static int LuaEmtHead( lua_State* L) ;
static int LuaEmtStdHead( lua_State* L) ;
static int LuaEmtMultiHead( lua_State* L) ;
static int LuaEmtSpecialHead( lua_State* L) ;
static int LuaEmtTcPos( lua_State* L) ;
static int LuaEmtStdTcPos( lua_State* L) ;
static int LuaEmtMultiTcPos( lua_State* L) ;
static int LuaEmtModifyAxisPosition( lua_State* L) ;
static int LuaEmtModifyAxisDirection( lua_State* L) ;
static int LuaEmtModifyAxisStroke( lua_State* L) ;
static int LuaEmtModifyAxisHome( lua_State* L) ;
static int LuaEmtModifyHeadAuxDirection( lua_State* L) ;
static int LuaEmtModifyExitPosition( lua_State* L) ;
static int LuaEmtAddRapidStart( lua_State* L) ;
static int LuaEmtAddRapidMove( lua_State* L) ;
static int LuaEmtAddLinearMove( lua_State* L) ;
static int LuaEmtAddArcMove( lua_State* L) ;
static int LuaEmtAddClimb( lua_State* L) ;
static int LuaEmtRemoveClimb( lua_State* L) ;
static int LuaEmtAddRise( lua_State* L) ;
static int LuaEmtRemoveRise( lua_State* L) ;
static int LuaEmtGetMoveType( lua_State* L) ;
static int LuaEmtGetAxesPos( lua_State* L) ;
static int LuaEmtGetBackAuxDir( lua_State* L) ;
static int LuaEmtGetInitialAxesPos( lua_State* L) ;
static int LuaEmtGetFinalAxesPos( lua_State* L) ;
static int LuaEmtGetCurrAxesHomePos( lua_State* L) ;
static int LuaEmtLinkRawPartToGroup( lua_State* L) ;
static int LuaEmtGetAllLinkedRawParts( lua_State* L) ;
static int LuaEmtUnlinkRawPartFromGroup( lua_State* L) ;
static int LuaEmtUnlinkAllRawPartsFromGroups( lua_State* L) ;
static int LuaEmtLinkFixtureToGroup( lua_State* L) ;
static int LuaEmtUnlinkFixtureFromGroup( lua_State* L) ;
static int LuaEmtUnlinkAllFixturesFromGroups( lua_State* L) ;
static int LuaEmtLinkPartToGroup( lua_State* L) ;
static int LuaEmtUnlinkPartFromGroup( lua_State* L) ;
static int LuaEmtUnlinkAllPartsFromGroups( lua_State* L) ;
static int LuaEmtWrite( lua_State* L) ;
static int LuaEmtSetOutstrokeInfo( lua_State* L) ;
static int LuaEmtSetLastError( lua_State* L) ;
static int LuaEmtSetWarning( lua_State* L) ;
static int LuaEmtAddCollisionObj( lua_State* L) ;
static int LuaEmtAddCollisionObjEx( lua_State* L) ;
static int LuaEmtRemoveCollisionObj( lua_State* L) ;
static int LuaEmtGetCollisionObj( lua_State* L) ;
static int LuaEmtExecCollisionCheck( lua_State* L) ;
static int LuaEmtOnCollision( lua_State* L) ;
static int LuaEmtSetToolForVmill( lua_State* L) ;
static int LuaEmtAddToolForVmill( lua_State* L) ;
static int LuaEmtEnableToolsForVmill( lua_State* L) ;
static int LuaEmtMoveAxes( lua_State* L) ;
static int LuaEmtSaveCmd( lua_State* L) ;
} ;
//----------------------------------------------------------------------------
template <typename T>
bool
Machine::LuaSetGlobVar( const std::string& sVar, const T& Val)
{
// imposto contesto corretto
int nOldCtx = ExeGetCurrentContext() ;
if ( nOldCtx != m_nContextId)
ExeSetCurrentContext( m_nContextId) ;
// imposto l'oggetto corrente per Lua
Machine* pOldMchLua = m_pMchLua ;
m_pMchLua = this ;
// eseguo l'assegnamento
bool bOk = ::LuaSetGlobVar( m_LuaMgr.GetLuaState(), sVar, Val) ;
// ripristino contesto originale
if ( nOldCtx != m_nContextId)
ExeSetCurrentContext( nOldCtx) ;
// ripristino dell'oggetto corrente per Lua
m_pMchLua = pOldMchLua ;
return bOk ;
}
//----------------------------------------------------------------------------
template <typename T>
bool
Machine::LuaGetGlobVar( const std::string& sVar, T& Val)
{
// imposto contesto corretto
int nOldCtx = ExeGetCurrentContext() ;
if ( nOldCtx != m_nContextId)
ExeSetCurrentContext( m_nContextId) ;
// imposto l'oggetto corrente per Lua
Machine* pOldMchLua = m_pMchLua ;
m_pMchLua = this ;
// eseguo la lettura
bool bOk = ::LuaGetGlobVar( m_LuaMgr.GetLuaState(), sVar, Val) ;
// ripristino contesto originale
if ( nOldCtx != m_nContextId)
ExeSetCurrentContext( nOldCtx) ;
// ripristino dell'oggetto corrente per Lua
m_pMchLua = pOldMchLua ;
return bOk ;
}