TG Motion  version 421 - 4033/904 cnc 121
Real-time system for controlling servo drives and I/O modules
TGM_CNC.h File Reference

Main include file for CNC module of TG Motion. More...

#include <stdint.h>
#include <string.h>
#include <assert.h>
#include <math.h>

Go to the source code of this file.

Classes

struct  SIMPLE_INFO
 Auxiliary G-code functions use this structure. More...
 
struct  GM_PARAMS_ENHANCED
 Extended actual parameters. More...
 
struct  P10DOUBLE
 This structure defines 10 coordinates of double type (8 bytes) More...
 
struct  P10BOOL
 Structure similar to P10DOUBLE, using integers. Its use is for setting additional flags to axes. More...
 
struct  SIMPLE_GM_PARAMS_BASE
 Describes one G-code part. More...
 
struct  SIMPLE_GM_PARAMS_WIN32
 Describes one G-code part. More...
 
struct  CALLBACK_INFO
 Structure for transmitting information for the function ToolChainCore_GetLastError and for the callback functions AddOutputLogFunc, SetStatusBarTextFunc, MathWarningFunc. More...
 
struct  GCODE_FEED
 Definition of default feeds. More...
 
struct  AXIS_LIMITS
 Limits for one axis. More...
 
struct  GCODE_CORRECTION
 Definition of corrections. More...
 
struct  ARC_FEED_TABLE
 Table of speeds, relative arc speeds in relation to radius. More...
 
struct  INTERNAL_MFUNC_INSERT_TABLE
 Values of inserted M functions. More...
 
struct  GCODE_PARAMETERS
 Structure for setting G-code properties. More...
 
struct  GCODE_SIZE
 Initial position, end position and size. More...
 
struct  GCODE_INFO
 G-code size. More...
 
struct  DLL_INIT_STRUCT
 Initialization structure. Used by ToolChainCore_Init. More...
 
struct  MACHINE_PARAMETERS
 Machine parameters. More...
 
struct  INTERPOLATOR_CMD_PARAMS
 One direct command to interpolator. More...
 
struct  CNC_CALC_INIT_DATA
 Initialization structure. More...
 
struct  CNC_CALC_RETURN_VALUE
 Holds changed G-code parts. More...
 

Macros

#define COMM_DLL_VERSION   355
 communication library (TGMmini.dll) version
 
#define INVALID_VALUE   (MAX_FLOAT / 2.)
 this "nonsense" value is used for not used G-code addresses.
 
#define _countof(array)   (sizeof(array)/sizeof(array[0]))
 determine number of elements in an array (not bytes)
 
#define MAX_FUNC_ADDRESSES   ('Z' - 'A' + 1)
 number of letters in alphabet, i.e. all the G-code addresses
 
#define TOOL_CHAIN_BAD_INTR_INDEX   (-2)
 ToolChainCore_XXX functions return codes. More...
 
#define TOOL_CHAIN_ERROR   (-1)
 unknown error (pointer is null, invalid parameter value, etc...)
 
#define TOOL_CHAIN_SUCCESS   0
 OK value.
 
#define TOOL_CHAIN_XEXEC   1
 error during execution
 
#define TOOL_CHAIN_XBREAK   2
 execution has been interrupted
 
#define ACTUAL_N_AXES   (sizeof(P10DOUBLE) / sizeof(double))
 number of axes used in CNC module (currently 10)
 
#define START_CNC_SIMULATION   10
 Available CNC module regimes: More...
 
#define START_CNC_TEST   20
 Start CNC module in test mode (for the time being identical to simulation mode)
 
#define START_CNC_FORWARD   30
 Start CNC module forward (normal and most used mode)
 
#define START_CNC_FORWARD_NO_MFUNC   31
 Start CNC module forward, but all the M functions are ignored (skipped)
 
#define START_CNC_BACKWARD   32
 Start CNC module in backward direction. The backward movement buffer is limited to 1000 parts. M functions are skipped.
 
#define START_CNC_FORWARD_SKIP_FIRST_M   33
 Start CNC module forward. The first M function is skipped, then continue like in regime 30.
 
#define START_CNC_CONNECT   40
 The system calculates the connection point. No machine move is performed.
 
#define START_CNC_CONNECT_MOVE   41
 The system is moving to the connection point.
 
#define START_CNC_GOTO_POSITION   50
 The system moves to specified position.
 
#define START_CNC_CALCULATING   60
 Internal calculations are performed. No movement.
 
#define START_CNC_HELP   999
 internal use only
 
#define RESET_CNC_NO_G92   1
 Additional regimes for ToolChainCore_ResetCNC function. More...
 
#define NUMBER_OF_VARIABLES   100
 Max number of user Pxx parameters.
 
#define SUB_PARS   50
 Number of system parameters (P100 - P149)
 
#define MAX_DECLARED_PARAMS   (NUMBER_OF_VARIABLES + SUB_PARS)
 Total number of parameters.
 
#define MAXLABELLENGTH   40
 Max label length in the G-code (in characters)
 
#define MAX_M_FUNC_IN_G   (4)
 
#define CORR_STRATEGY_G41_ALREADY_CORRECTED   0
 G41, G42 means already corrected coordinate; G40 says that only the end of the following motion will be left uncorrected.
 
#define CORR_STRATEGY_G41_STARTS_CORRECTION   1
 G41, G42 only corrects the end of the following motion; G40 says the end of the previous motion will not be corrected.
 
#define CORR_STRATEGY_OLD_VERSION   0x80000000
 
#define CORR_STRATEGY_G00_WITHOUT_CORR   0x40000000
 If this bit is set, G00 is always without correction.
 
#define CORR_STRATEGY_FORCE_TO_CONTINUE   0x20000000
 
#define CORR_STRATEGY_CHECK_ORIGINAL_GCODE   0x02000000
 checks continuity of the G-code with the given tolerance (see GCODE_PARAMETERS::tolerance).
 
#define CORR_STRATEGY_REMOVE_LAST_ARC   0x01000000
 removes the last arc of a closed conture (in the case that the arc is the exit of the conture) if the equidistants do not cross
 
#define CORR_STRATEGY_REMOVE_FIRST_ARC   0x00800000
 removes the first arc of a closed conture (in the case that the arc is the approach of the conture) if the equidistants do not cross
 
#define CORR_STRATEGY_NO_ADD_R   0x00400000
 
#define CORR_STRATEGY_REMOVE_SMALL_ARCS   0x00200000
 
#define CORR_STRATEGY_ALLOW_REVERSE_LINES   0x00100000
 Allow more exact calculation of the tool compensation by reverse search with the buffer. Slows down the calculation.
 
#define CORR_STRATEGY_REMOVE_CROSSES   0x00080000
 After the calculation, if there are crossed parts (which are not crossed in the original G-code), these parts are removed.
 
#define CORR_STRATEGY_CONNECT_WRONG_BY_G1   0x00040000
 After correction calculation, if there are unconnected parts, connect them by inserted G1.
 
#define CORR_STRATEGY_CONNECT_WRONG_BY_MOVE   0x00020000
 
#define CORR_STRATEGY_ALLOW_FIRST_LAST_CROSS   0x00010000
 Allow crossing of the first and last part of the closed conture. In that case, parts inside are not removed.
 
#define CORR_STRATEGY_SEARCH_DEEP_10   0x00000100
 Search at least 10 parts for possible crosses.
 
#define CORR_STRATEGY_SEARCH_DEEP_50   0x00000200
 Search at least 50 parts for possible crosses.
 
#define CORR_STRATEGY_SEARCH_DEEP_100   0x00000300
 Search at least 100 parts for possible crosses.
 
#define CORR_STRATEGY_SEARCH_DEEP_500   0x00000400
 Search at least 500 parts for possible crosses.
 
#define CORR_STRATEGY_SEARCH_DEEP_1000   0x00000500
 Search at least 1000 parts for possible crosses.
 
#define CORR_STRATEGY_SEARCH_DEEP_2000   0x00000600
 Search at least 2000 parts for possible crosses.
 
#define CORR_STRATEGY_SEARCH_DEEP_ALL   0x00000700
 Search all parts for possible crosses.
 
#define CORR_STRATEGY_DEFAULT_DEEP   1000
 Default deep search number. Search at least 1000 G-code parts for possible crosses.
 
#define F_BY_GCODE   0
 Feed is fully defined in G-code.
 
#define F_BY_PARAMETERS   1
 All feeds are set by values in motion array.
 
#define F_BY_PARAMETERS_FP_BY_GCODE   2
 All feeds are set by values in motion array but can be overriden by FP address.
 
#define GCODE_ALLOWED_CIRC_CENTER_ACCURACY   0
 
#define LOCAL_CORE_MODE_TGM   0
 CNC module runs in real-time domain (TGMotion engine)
 
#define LOCAL_CORE_MODE_DLL   1
 CNC module runs in the context of OS (as .DLL or .so libraries - DLL engine)
 
#define LOCAL_CORE_MODE_OFFLINE   2
 CNC module runs without TG Motion (simulation and test only)
 
#define CALLBACK_CALLTYPE   TOOLCHAIN_CALLTYPE
 Callbacks uses the same calling convention as exported functions.
 
#define APP_AddOutputLogFunc   1
 callback index number
 
#define APP_SetStatusBarTextFunc   2
 callback index number
 
#define APP_IsDebugModeFunc   3
 callback index number
 
#define APP_IsVerboseModeFunc   4
 callback index number
 
#define APP_GetLibPathFunc   5
 callback index number
 
#define APP_GetToolPathFunc   6
 callback index number
 
#define APP_GetSystemPathFunc   7
 callback index number
 
#define APP_GetFileTimeStampFunc   10
 callback index number
 
#define APP_DoYieldFunc   11
 callback index number
 
#define APP_ReadIniStringFunc   12
 callback index number
 
#define APP_ReadIniDoubleFunc   13
 callback index number
 
#define APP_ReadIniIntFunc   14
 callback index number
 
#define APP_DispRunInfoAndWaitFunc   15
 callback index number
 
#define APP_DispRunInfoFunc   16
 callback index number
 
#define APP_IsBreakpointFunc   17
 callback index number
 
#define APP_DispAndLocateErrorFunc   18
 callback index number
 
#define APP_DispLastInfoFunc   19
 callback index number
 
#define APP_IsStepModeFunc   20
 callback index number
 
#define APP_IsHandControlFunc   21
 callback index number
 
#define APP_SetRegimeFromUserKeyFunc   22
 callback index number
 
#define APP_ExecMenuCommandFromUserKeyFunc   23
 callback index number
 
#define APP_MaxFuncNumber   1000
 last function in APP group
 
#define DRV_InitializeFunc   1001
 callback index number
 
#define DRV_GFunc   1002
 callback index number
 
#define DRV_MFunc   1003
 callback index number
 
#define ConnectPointCalcStartFuncNumber   1004
 callback index number
 
#define ConnectPointCalcFunc_UseReturnValues   1
 Return value of ConnectPointCalcFunc or ConnectPointCalcEndFunc values are used.
 
#define ConnectPointCalcFuncNumber   1005
 callback index number
 
#define ConnectPointCalcEndFuncNumber   1006
 callback index number
 
#define DRV_MaxFuncNumber   2000
 last function number in DRV group
 
#define MATH_WarningFunc   2001
 callback index number
 
#define MATH_MaxFuncNumber   3000
 last function number in MATH group
 
#define CNC_CALC_LOAD_ALL   0
 load plug-in to both DLL and TGMmotion (real-time)
 
#define CNC_CALC_LOAD_DLL_ONLY   1
 load plug-in to DLL core (engine) only (see also DLL_INIT_STRUCT::Local_Core_Mode and LOCAL_CORE_MODE_DLL)
 
#define CNC_CALC_LOAD_TGM_ONLY   2
 load plug-in to TGMmotion engine only (LOCAL_CORE_MODE_TGM)
 
#define CNC_CALC_MFUNC_OFFSET   10000
 M function number offset to distinguish between G and M functions in SIMPLE_GM_PARAMS_BASE::m_func field.
 
#define CNC_CALC_DISABLE_AUTOMATIC_GCODEINDEX_UPDATE_BIT   0x01
 if used, TGMotion does not automatically update GCodeIndex value of the inserted parts
 
#define CNC_CALC_MAX_STATIC_RETURNED_PARTS   8
 
#define CNC_CALC_RETURN_ERROR   (-1)
 Notify TGMotion of an error inside plug-in. More...
 
#define CNC_CALC_RETURN_IGNORE   0
 The call to the function is ignored and original part is used (no modification). More...
 
#define CNC_CALC_RETURN_USE   1
 TG Motion use the values in the CNC_CALC_RETURN_VALUE struct. The original part is not used. If needed, must be copied by the plug-in. More...
 
#define CNC_CALC_RETURN_OK   1
 Success value of non-calc funcions. More...
 
#define CNC_CALC_RETURN_FEED_ONLY   2
 Only the CNC_CALC_RETURN_VALUE::dblFeed value is used to modify the part feed, all other values are ignored. More...
 
#define G_FUNC_SETTINGS   900
 Special G-code function number. See Special settings function G900.
 

Typedefs

typedef const wchar_t * TGM_LPCTSTR
 default const string type: Win UNICODE (16bit), Linux UTF-8 (8bit)
 
typedef wchar_t * TGM_LPTSTR
 default string type: Win UNICODE (16bit), Linux UTF-8 (8bit)
 
typedef const char * TGM_LPCSTR
 explicit const UTF-8 (8bit ANSI) string type
 
typedef int32_t CALLBACK_CALLTYPE FuncPrototype(intptr_t dwUserData)
 Generic callback function prototype.
 
typedef int32_t CALLBACK_CALLTYPE AddOutputLogFunc(intptr_t dwUserData, int32_t tab, TGM_LPCTSTR info, CALLBACK_INFO *callBackInfo)
 Writes text to output log. More...
 
typedef int32_t CALLBACK_CALLTYPE SetStatusBarTextFunc(intptr_t dwUserData, int32_t pane, TGM_LPCTSTR strText, CALLBACK_INFO *callBackInfo)
 Display informational text in the status line of the application. More...
 
typedef int32_t CALLBACK_CALLTYPE IsDebugModeFunc(intptr_t dwUserData)
 Ask if debug regime is enabled. More...
 
typedef int32_t CALLBACK_CALLTYPE IsVerboseModeFunc(intptr_t dwUserData)
 Ask if verbose regime is enabled. More...
 
typedef TGM_LPCTSTR CALLBACK_CALLTYPE GetLibPathFunc(intptr_t dwUserData)
 Returns path to external G functions stored as G-code on the disk. More...
 
typedef TGM_LPCTSTR CALLBACK_CALLTYPE GetToolPathFunc(intptr_t dwUserData)
 Returns path to files describing tools geometry. Only for lathe. More...
 
typedef TGM_LPCTSTR CALLBACK_CALLTYPE GetSystemPathFunc(intptr_t dwUserData)
 Returns path to system files. Not yet used by CNC module. More...
 
typedef int64_t CALLBACK_CALLTYPE GetFileTimeStampFunc(intptr_t dwUserData, uint32_t fileIdx)
 returns time stamp of a given file (usually time in ms since epoch) More...
 
typedef int32_t CALLBACK_CALLTYPE DoYieldFunc(intptr_t dwUserData, int32_t messageOnly)
 Switch control to other thread. LOCAL_CORE_MODE_DLL only. More...
 
typedef void CALLBACK_CALLTYPE ReadIniStringFunc(intptr_t dwUserData, TGM_LPCTSTR section, TGM_LPCTSTR key, TGM_LPCTSTR defValue, TGM_LPTSTR buffer, uint32_t bufferSizeInCharacters)
 Read string from .INI file. More...
 
typedef double CALLBACK_CALLTYPE ReadIniDoubleFunc(intptr_t dwUserData, TGM_LPCTSTR section, TGM_LPCTSTR key, double defValue)
 Read double value from .INI file. More...
 
typedef int32_t CALLBACK_CALLTYPE ReadIniIntFunc(intptr_t dwUserData, TGM_LPCTSTR section, TGM_LPCTSTR key, int32_t defValue)
 Read integer value from .INI file. More...
 
typedef int32_t CALLBACK_CALLTYPE DispRunInfoAndWaitFunc(intptr_t dwUserData, uint32_t editorLine, int32_t fileIdx, TGM_LPCTSTR statusInfo, int32_t bNoBreakpoints, int32_t bForceToWait, const double *params, const uint32_t maxParams)
 Display info about the actual G-code part. More...
 
typedef int32_t CALLBACK_CALLTYPE DispRunInfoFunc(intptr_t dwUserData, uint32_t editorLine, int32_t fileIdx, TGM_LPCTSTR statusInfo, const SIMPLE_GM_PARAMS_WIN32 *pCmd)
 Display info about the actual G-code part. More...
 
typedef int32_t CALLBACK_CALLTYPE IsBreakpointFunc(intptr_t dwUserData, uint32_t editorLine, int32_t fileIdx)
 Determines if there is a breakpoint on given G-code file line. More...
 
typedef int32_t CALLBACK_CALLTYPE DispAndLocateErrorFunc(intptr_t dwUserData, uint32_t editorLine, int32_t fileIdx, TGM_LPCTSTR errString, CALLBACK_INFO *callBackInfo)
 This function is called in case of an error. More...
 
typedef int32_t CALLBACK_CALLTYPE DispLastInfoFunc(intptr_t dwUserData)
 Called when G-code execution finished (OK and NOK) More...
 
typedef int32_t CALLBACK_CALLTYPE IsStepModeFunc(intptr_t dwUserData)
 Ask if execute G-code step by step (part by part). Not yet used. More...
 
typedef int32_t CALLBACK_CALLTYPE IsHandControlFunc(intptr_t dwUserData)
 Ask if application is in hand control (service mode). Not yet used. More...
 
typedef int32_t CALLBACK_CALLTYPE SetRegimeFromUserKeyFunc(intptr_t dwUserData, int32_t key)
 Reserved. More...
 
typedef int32_t CALLBACK_CALLTYPE ExecMenuCommandFromUserKeyFunc(intptr_t dwUserData, int key)
 Reserved. More...
 
typedef int32_t CALLBACK_CALLTYPE DriverInitializeFunc(intptr_t dwUserData, double *params, uint32_t nParams, int32_t bTestMode)
 Called always before G-code execution. More...
 
typedef int32_t CALLBACK_CALLTYPE DriverGFunc(intptr_t dwUserData, const SIMPLE_GM_PARAMS_WIN32 *v)
 Called to simulate G function. More...
 
typedef int32_t CALLBACK_CALLTYPE DriverMFunc(intptr_t dwUserData, const SIMPLE_GM_PARAMS_WIN32 *v)
 Called to simulate M function. More...
 
typedef int32_t CALLBACK_CALLTYPE ConnectPointCalcStartFunc(intptr_t dwUserData, const int32_t nType, const uint32_t nCoords, const double *coords, const uint32_t bitCodedAxesForCalc)
 Initiate user connection calculation. More...
 
typedef int32_t CALLBACK_CALLTYPE ConnectPointCalcFunc(intptr_t dwUserData, const SIMPLE_GM_PARAMS_WIN32 *part, double *calcSquareDistanceFromCoords, P10DOUBLE *calcConnectPoint)
 Calculate distance from initial tool point to a give G-code part. More...
 
typedef int32_t CALLBACK_CALLTYPE ConnectPointCalcEndFunc(intptr_t dwUserData, SIMPLE_GM_PARAMS_WIN32 *partToBeConnectedTo, P10DOUBLE *connectPosToBeMovedTo)
 End of connection calculation. More...
 
typedef int32_t CALLBACK_CALLTYPE MathWarningFunc(intptr_t dwUserData, CALLBACK_INFO *pCallbackInfo)
 Called in case of warning issued during tool diameter compensation calculation. More...
 

Enumerations

enum  cnc_status : int32_t {
  statusOFFLINE = -2, statusSENDING_GCODE_TO_REMOTE_DEVICE = -3, statusINVALID = 0, statusCOMPILING = 1,
  statusCOMPILE_FINISHED = -1, statusSIMULATING = START_CNC_SIMULATION, statusSIMULATION_END = -10, statusSIMULATION_BREAK = -11,
  statusTEST = START_CNC_TEST, statusTEST_END = -20, statusTEST_BREAK = -21, statusTRAJECTORY_START = -30,
  statusTRAJECTORY_BREAK = -31, statusTRAJECTORY_END = -32, statusTRAJECTORY_BREAK_M0 = -33, statusFORWARD = START_CNC_FORWARD,
  statusFORWARD_NO_MFUNC = START_CNC_FORWARD_NO_MFUNC, statusBACKWARD = START_CNC_BACKWARD, statusFORWARD_SKIP_FIRST_M = START_CNC_FORWARD_SKIP_FIRST_M, statusCONNECTING = 40,
  statusCONNECT_MOVE = 41, statusHAND_MOVE = 50, statusOUT_OF_TRAJECTORY = -50, statusCALCULATING = START_CNC_CALCULATING,
  statusSTART_M_FUNCS = 70, statusSTOP_M_FUNCS = 80, statusCONNECT_INS_M_FUNCS = 90, statusNONSENSE = -1234
}
 StatusCNC return codes. More...
 
enum  connect_type : int32_t {
  connectBY_COORD = 0, connectBY_LINE_START = 1, connectBY_LINE_END = 2, connectBY_COORD_GO = 10,
  connectBY_LINE_START_GO = 11, connectBY_LINE_END_GO = 12, connectBY_M_FUNC_COUNT = 20, connectBY_M_FUNC_COUNT_REL = 21,
  connectBY_GCODE_INDEX = 30, connectBY_GCODE_INDEX_ACTUAL_COORD = 31, connectBY_GCODE_INDEX_END = 32, connectBY_COORD_GO_BUFFERED = 40,
  connectBY_LINE_START_GO_BUFFERED = 41, connectBY_LINE_END_GO_BUFFERED = 42
}
 Connection modes (ToolChainCore_ConnectCNCEx_Plane) More...
 
enum  axis_idx : int32_t {
  AXIS_NONE = -1, AXIS_X = 0, AXIS_Y, AXIS_Z,
  AXIS_C, AXIS_B, AXIS_U, AXIS_V,
  AXIS_W, AXIS_A, AXIS_O, AXIS_S = 100,
  AXIS_T, AXIS_IO, AXIS_S2, AXIS_XY = 200
}
 Axes numbers, together with special axis types. Assignment of the axes to array indexes is fixed, i.e. the first axis (index 0) is always X axis, etc... Special axes are used internally and have no relationship to array indexes. More...
 

Functions

TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_Init (DLL_INIT_STRUCT *pInitValues)
 Init the CNC module. More...
 
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_LoadFromIni (int32_t intIdx, TGM_LPCTSTR iniFile, int32_t *pnMaxCores)
 Loads DLL chain from INI file. More...
 
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_DestroyCNC (int32_t intIdx)
 Finishes work with DLLs and frees all the alloctaed memry. More...
 
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_SetGCodeParameters (int32_t intIdx, const GCODE_PARAMETERS *params)
 Sets parameters (properties) of G-code. More...
 
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_GetGCodeParameters (int32_t intIdx, GCODE_PARAMETERS *params)
 Obtains values set with ToolChainCore_SetGCodeParameters, or read from .INI file during startup. More...
 
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_StatusCNC (int32_t intIdx)
 Actual CNC module state. More...
 
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_GetPos (int32_t intIdx, int32_t regime, SIMPLE_GM_PARAMS_WIN32 *pos, GM_PARAMS_ENHANCED *enhParams)
 Returns current position of machine axes together with additonal informations. More...
 
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_CompileFromFile (int32_t intIdx, TGM_LPCTSTR fileName)
 Compiles G-code from file. More...
 
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_CompileFromMemory (int32_t intIdx, TGM_LPCTSTR fileName, TGM_LPCSTR mainCode)
 Compiles G-code from string in memory. More...
 
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_IsBusy (int32_t intIdx)
 Checks if the machine is executing G-code. More...
 
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_StartCNCEx (int32_t intIdx, int32_t regime, TGM_LPCSTR strAddGCode)
 Start or continue G-code. More...
 
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_ResetCNC (int32_t intIdx, int32_t regime, const uint32_t nCoords, const double *coords)
 Sets the initial position for G-code. More...
 
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_StopCNCEx (int32_t intIdx, TGM_LPCSTR strAddCode)
 Stops motion or connecting (break). More...
 
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_ConnectCNCEx_Plane (int32_t intIdx, int32_t nType, const uint32_t nCoords, const double *coords, TGM_LPCSTR strAddCode, uint32_t bitCodedAxesForCalc, uint32_t bitCodedAxesForConnect, int32_t trajectoryStateAfterConnect)
 Move to the nearest point of trajectory of G-code with possibility of M function insertion after the connection movement. More...
 
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_GoToPosition (int32_t intIdx, const uint32_t nCoords, const double *coords)
 Manual control. More...
 
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_GoToPositionEx (int32_t intIdx, const SIMPLE_GM_PARAMS_WIN32 *pDest)
 Extended manual control. More...
 
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_MFunc (int32_t intIdx, const SIMPLE_GM_PARAMS_WIN32 &fun, int32_t bDirectToPLC)
 Send M function directly to system. More...
 
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_FileToIdx (int32_t intIdx, TGM_LPCTSTR fileName)
 Returns index number of the file with a given name. If the file name is new, it returns a new number. More...
 
TOOLCHAIN_DLL_EXPORT TGM_LPCTSTR TOOLCHAIN_CALLTYPE ToolChainCore_IdxToFile (int32_t intIdx, int32_t fileIdx)
 Returns the complete filename of file with relevant number (index). More...
 
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_SetRelFeed (int32_t intIdx, double relFeed)
 Sets the feed override (relative speed). More...
 
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_SetCallBack (int32_t intIdx, int32_t fceNo, intptr_t dwUserData, FuncPrototype *funcPtr)
 Sets callback function. More...
 
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_GetLastError (int32_t intIdx, CALLBACK_INFO *pLastErrorInfo)
 Returns the last error, if any. More...
 
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_SetBreakpoint (int32_t intIdx, uint32_t editorLine, int32_t fileIdx)
 Set breakpoint in the G-code. More...
 
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_GetGCodeSizeInfo (int32_t intIdx, GCODE_INFO *pInfo)
 Identifies size (dimension) of G-code. More...
 
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_GetStructuresSize (int32_t intIdx, uint32_t nItems, uint32_t *items)
 Returns bytes sizes of internal structures. More...
 
TOOLCHAIN_DLL_EXPORT TGM_LPCTSTR TOOLCHAIN_CALLTYPE ToolChainCore_GetVersionString (int32_t intIdx)
 Returns the DLLs version number and the date and time of compilation. More...
 
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_GetMachineParameters (int32_t intIdx, MACHINE_PARAMETERS *pParameters)
 Returns actual values of MACHINE_PARAMETERS. More...
 
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_SetMachineParameters (int32_t intIdx, const MACHINE_PARAMETERS *pParameters)
 Sets new values of MACHINE_PARAMETERS. More...
 
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_LoadCNCCalcPlugIn (TGM_LPCTSTR fileName, uint32_t loadFlags, int64_t userValue)
 Load CNC Calc plugin (see CNC Calc plug-in exported functions) More...
 
CNC_CALC_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE CNC_Calc_Load (const CNC_CALC_INIT_DATA *pInitData)
 Plug-in DLL initialization. More...
 
CNC_CALC_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE CNC_Calc_Unload ()
 Plug-in DLL cleanup. More...
 
CNC_CALC_DLL_EXPORT uint32_t TOOLCHAIN_CALLTYPE CNC_Calc_Get_Structures_Size (uint32_t structureIdx)
 Check structure sizes - test for compatibility. More...
 
CNC_CALC_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE CNC_Calc_Get_Compatibility_IDs (uint32_t *pID_COMPATIBILITY, uint32_t *pID_MEMORY_COMPATIBILITY, uint32_t *pID_CNC_COMPATIBILITY)
 Returns compatibility numbers at the time of plug-in build. More...
 
CNC_CALC_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE CNC_Calc_Start (uint32_t intIdx, int32_t regime, const SIMPLE_GM_PARAMS_BASE *pInitPos, CNC_CALC_RETURN_VALUE *pChangedParts)
 Called before the G-code execution. More...
 
CNC_CALC_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE CNC_Calc_GFunc (uint32_t intIdx, const SIMPLE_GM_PARAMS_BASE *pGFunc, CNC_CALC_RETURN_VALUE *pChangedParts)
 Called for any G function inside G-code. More...
 
CNC_CALC_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE CNC_Calc_MFunc (uint32_t intIdx, const SIMPLE_GM_PARAMS_BASE *pMFunc, CNC_CALC_RETURN_VALUE *pChangedParts)
 Called for any M function inside G-code. More...
 
CNC_CALC_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE CNC_Calc_Finish (uint32_t intIdx, const SIMPLE_GM_PARAMS_BASE *pFinishMFunc, CNC_CALC_RETURN_VALUE *pChangedParts)
 Called as the last function of the G-code. More...
 

Detailed Description

Main include file for CNC module of TG Motion.


Author
Jan Vasina

Release notes

  • 09.04.2018 Initial release
  • 25.06.2018 Added G900 function description
  • 03.10.2018 CNC plug-ins, new callback function for connecting

Definition in file TGM_CNC.h.

Macro Definition Documentation

◆ TOOL_CHAIN_BAD_INTR_INDEX

#define TOOL_CHAIN_BAD_INTR_INDEX   (-2)

ToolChainCore_XXX functions return codes.

invalid interpolator index

Definition at line 169 of file TGM_CNC.h.

◆ START_CNC_SIMULATION

#define START_CNC_SIMULATION   10

Available CNC module regimes:

Start CNC module in simulation mode (i.e. callback of DRV group are called)

Definition at line 179 of file TGM_CNC.h.

◆ RESET_CNC_NO_G92

#define RESET_CNC_NO_G92   1

Additional regimes for ToolChainCore_ResetCNC function.

do not change machine position

Definition at line 192 of file TGM_CNC.h.

◆ MAX_M_FUNC_IN_G

#define MAX_M_FUNC_IN_G   (4)

max number of M functions inside one G function
e.g. G1 X... Y... M3...
will be interpreted as

M3
G1 X... Y...

Definition at line 213 of file TGM_CNC.h.

◆ CORR_STRATEGY_OLD_VERSION

#define CORR_STRATEGY_OLD_VERSION   0x80000000

If this bit is set, the mode of compatibility with the old system is set. Specifically, the first G41/G42 is ignored, if there is no motion in front of it. Further, the G40 - G41/G42 pair is ignored, if they follow closely one by one (i.e. no motion between G40 and G41/G42).

Definition at line 1281 of file TGM_CNC.h.

◆ CORR_STRATEGY_FORCE_TO_CONTINUE

#define CORR_STRATEGY_FORCE_TO_CONTINUE   0x20000000

In the case of wrong G-code (impossible to calculate tool compensation), do not throw an error and continue. Usable for simulation only.

Definition at line 1288 of file TGM_CNC.h.

◆ CORR_STRATEGY_NO_ADD_R

#define CORR_STRATEGY_NO_ADD_R   0x00400000

if possible, do not connect two parts by and additional arc (with radius equal to tool radius), but uses its cross point. The allowed distance is specified as a multiple of tool radius (see GCODE_PARAMETERS::tolerance)

Definition at line 1301 of file TGM_CNC.h.

◆ CORR_STRATEGY_REMOVE_SMALL_ARCS

#define CORR_STRATEGY_REMOVE_SMALL_ARCS   0x00200000

After tool compensation calculation, there could be arcs with negative or very small radius. If the calculated radius of such arcs is smaller than a value given in GCODE_PARAMETERS::tolerance[GCODE_MINIMAL_ALLOWED_ARC_R], the arc will be removed. This bit is usually set.

Definition at line 1306 of file TGM_CNC.h.

◆ CORR_STRATEGY_CONNECT_WRONG_BY_MOVE

#define CORR_STRATEGY_CONNECT_WRONG_BY_MOVE   0x00020000

After correction calculation, if there are unconnected parts, connect them by move of starting point to endpoint of the previous part. Only for G1. G2/G3 are always connected by G1 if this bit is set.

Definition at line 1319 of file TGM_CNC.h.

◆ GCODE_ALLOWED_CIRC_CENTER_ACCURACY

#define GCODE_ALLOWED_CIRC_CENTER_ACCURACY   0

Additional dynamic correction in relation to speed for G42 in percent, carried out by interpolator

Definition at line 1650 of file TGM_CNC.h.