TG Motion  version 421 - 4033/904 cnc 121
Real-time system for controlling servo drives and I/O modules
Exported functions

Macros

#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)
 

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...
 

Detailed Description

The following functions are exported from SF_TCh.dll or libSF_TCh.so dynamic libraries.

Function Documentation

◆ ToolChainCore_Init()

TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_Init ( DLL_INIT_STRUCT pInitValues)

Init the CNC module.

This should be the first called function of the CNC module. If not used, reasonable defaults are used (all paths set to actual directory and core mode set to TGMotion).

Returns
Error code Description
-1 any of the members in pInitValues is nullptr
0 success
Parameters
pInitValuespointer to DLL_INIT_STRUCT with initialization parameters

◆ ToolChainCore_LoadFromIni()

TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_LoadFromIni ( int32_t  intIdx,
TGM_LPCTSTR  iniFile,
int32_t *  pnMaxCores 
)

Loads DLL chain from INI file.

Returns
Error code Description
TOOL_CHAIN_SUCCESS success
TOOL_CHAIN_XEXEC failure
Parameters
intIdxCore index (0-2 on PC, 0 on TGMmini)
iniFileFull path of the .INI file
pnMaxCoresPointer to variable which recieves number of available cores in the system, can be nullptr

Call this function at the application startup

Note
Mandatory entries of the .INI file:
[Modules]
;##########################################################################################
Ext0=.CNC
FileFilter0=G-code (*.CNC)
Compiler0=SF_DComp2.DLL/{50281631-512A-4CA8-918F-5D9261C1CCAE}
Executor0=SF_DExec2.DLL/{77F514FD-9853-47FE-BC1C-A8B9B7D1C4E5}
Calculator0=SF_XYZMath2.DLL/{B9D8C5B4-1D4C-4D09-B005-84AA97ABD8DE}
CNC0=SF_XYZWorker2.DLL/{1FC66490-3191-4D6A-A798-B820B80FEE3D}
;##########################################################################################
[CNC]
Driver=SF_RTDrv2.DLL/{C76DF33D-33BA-444B-A488-2A783367C122}
NAxes=10 ; allowed values 2 - 10

◆ ToolChainCore_DestroyCNC()

TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_DestroyCNC ( int32_t  intIdx)

Finishes work with DLLs and frees all the alloctaed memry.

Should be called only before the main .EXE file exits. Must be called for all cores, returned by ToolChainCore_LoadFromIni.

Returns
Error code or 0 for success
Parameters
intIdxCore index (0-2 on PC, 0 on TGMmini)

◆ ToolChainCore_SetGCodeParameters()

TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_SetGCodeParameters ( int32_t  intIdx,
const GCODE_PARAMETERS params 
)

Sets parameters (properties) of G-code.

Calling is possible also during G-code interruption ToolChainCore_StopCNCEx, but only some fields of GCODE_PARAMETERS can be changed (mostly the feeds). First call ToolChainCore_GetGCodeParameters, then change only the structure fields and then set the changed parameters by ToolChainCore_SetGCodeParameters.

Returns
Error code Description
-1 invalid parameter params or parameters cannot be chnaged at this moment (machine is in motion)
0 success
Parameters
intIdxCore index (0-2 on PC, 0 on TGMmini)
paramsPointer to GCODE_PARAMETERS structure with desired parameters

◆ ToolChainCore_GetGCodeParameters()

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.

Returns
Error code Description
-1 invalid parameter params or machine is in motion
0 success
Parameters
intIdxCore index (0-2 on PC, 0 on TGMmini)
paramsPointer to GCODE_PARAMETERS structure, which will be filled with set values

◆ ToolChainCore_StatusCNC()

TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_StatusCNC ( int32_t  intIdx)

Actual CNC module state.

Returns
One of the following value (see also enum cnc_status)
Status Description
0 Undefined status after starting .EXE or G-code is not loaded or an error occurred during G-code loading.
-2 remote device not connected (TGM_MINI, TGM_REMOTE)
-3 sending compiled G-code to TGM_MINI or TGM_REMOTE, percent progress in GCodeIndex
1 Compilation in progress
-1 Compilation completed (OK or NOK) - if OK call ToolChainCore_ResetCNC then ToolChainCore_StartCNCEx
10 Simulation in progress
-10 Simulation completed (OK or NOK) - if OK call ToolChainCore_ResetCNC then ToolChainCore_StartCNCEx
-11 Simulation interrupted by ToolChainCore_StopCNCEx (on trajectory)
20 Test in progress
-20 Test completed (OK or NOK)
-21 Test interrupted by ToolChainCore_StopCNCEx (on trajectory)
-30 Start of trajectory (after calling ToolChainCore_ResetCNC or at the end of backward move)
-31 Stop on trajectory (interruption with ToolChainCore_StopCNCEx or after connecting or emptying the backing buffer)
-32 End of trajectory
-33 Stop on trajectory - waits on M0 function in the G-code
30 Forward run on trajectory
31 Forward run on trajectory without M functions
32 Backward run on trajectory
33 Forward run on trajectory without initial M functions (up to the first G function)
40 Calculation of connecting to trajectory
41 Connecting to trajectory
50 Manual movement
-50 Stands outside trajectory
60 Internal calculations are in progress
70 Sending of starting M functions in progress (ToolChainCore_StartCNCEx)
80 Sending of ending M functions in progress (ToolChainCore_StopCNCEx)
90 Sending connecting M funcs

The return value is int32_t for compatibility with other programming languages. The CNC status is also returned by ToolChainCore_GetPos in the GM_PARAMS_ENHANCED structure, so there is no need to call this function if the ToolChainCore_GetPos is used.

◆ ToolChainCore_GetPos()

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.

Returns
Error code Description
-1 parameter pos is nullptr
-2 intIdx parameter out of range (must be 0-2 on PC, only 0 on TGMmini)
0 success
Parameters
intIdxCore index (0-2 on PC, 0 on TGMmini)
regimeRegime from which we want to obtain values:
Regime Description
10 Simulation
20 Test
Other values Machine
posPointer to SIMPLE_GM_PARAMS_WIN32 structure which will be filled with actual values.
enhParamsPointer to GM_PARAMS_ENHANCED structure which will be filled with actual values.

◆ ToolChainCore_CompileFromFile()

TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_CompileFromFile ( int32_t  intIdx,
TGM_LPCTSTR  fileName 
)

Compiles G-code from file.

Returns
Error code Description
-1 bad parametr fileName or compilation is in progress
-2 intIdx parameter out of range (must be 0-2 on PC, only 0 on TGMmini)
0 success
Parameters
intIdxCore index (0-2 on PC, 0 on TGMmini)
fileNameName of the G-code file (with full path)

Compilation is done in a separate thread. Function ToolChainCore_StatusCNC can be used to detect whether compilation is finished. After that ToolChainCore_GetLastError must be called to test whether an error occurred. Only after that the sequence of ToolChainCore_ResetCNC and ToolChainCore_StartCNCEx can be called.

◆ ToolChainCore_CompileFromMemory()

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.

Returns
Error code Description
-1 bad parametr fileName or compilation is in progress
-2 intIdx parameter out of range (must be 0-2 on PC, only 0 on TGMmini)
0 success
Parameters
intIdxCore index (0-2 on PC, 0 on TGMmini)
fileNameOptional name of the G-code file. Must not be nullptr.
mainCodeG-code text in the form of ANSI string (UTF8).

Compilation is done in a separate thread. Function ToolChainCore_StatusCNC can be used to detect whether compilation is finished. After that the ToolChainCore_GetLastError must be called to test whether an error occurred. Only after that the sequence of ToolChainCore_ResetCNC and ToolChainCore_StartCNCEx can be called.

◆ ToolChainCore_IsBusy()

TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_IsBusy ( int32_t  intIdx)

Checks if the machine is executing G-code.

Returns
0 if not busy, positive value if not busy, negative for error (intIdx parameter out of range - must be 0-2 on PC, only 0 on TGMmini)
Parameters
intIdxCore index (0-2 on PC, 0 on TGMmini)

◆ ToolChainCore_StartCNCEx()

TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_StartCNCEx ( int32_t  intIdx,
int32_t  regime,
TGM_LPCSTR  strAddGCode 
)

Start or continue G-code.

If the G-code is already started (in modes 30,31,32,33) and stopped with ToolChainCore_StopCNCEx, it can continue in modes 30, 31, 32. When modes 10 and 20 are interrupted, proceeding is only possible in the same mode. Before the first start or after completion of the whole trajectory ToolChainCore_ResetCNC must be called.

Returns
Error code Description
-1 Compilation is running or relevant mode cannot be launched (e.g. because the machine is in motion).
-2 intIdx parameter out of range (must be 0-2 on PC, only 0 on TGMmini)
0 success
Parameters
intIdxCore index (0-2 on PC, 0 on TGMmini)
regimeStart regime:
Value Description
10 Simulation
20 Test
30 CNC forward
31 CNC forward without M functions with feed defined in GCODE_PARAMETERS
32 CNC backward (without M functions)
33 CNC forward, M functions are ignored up to the first G function, then everything goes forward like CNC (30) (also speeds, accelerations etc...)
strAddGCodePointer to the G-code text (ANSI string) that will be sent BEFORE the main G-code. All G-functions are ignored in this G-code, only M functions will be sent. Can be nullptr.

◆ ToolChainCore_ResetCNC()

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.

Returns
Error code Description
-1 one or more invalid parameters
-2 intIdx parameter out of range (must be 0-2 on PC, only 0 on TGMmini)
0 success

If there is any activity in progress, it is ended, i.e. compilation is interrupted, G-code is stopped and ended.

Parameters
intIdxCore index (0-2 on PC, 0 on TGMmini)
regime---------— | -----------------— 1 | Only sets initial position for G-code, no setting of coordinates 10 | Setting of coordinates for simulation 20 | Setting of coordinates for testing Other values | Setting of coordinates for machine
nCoordsNumber of coordinates in coords array to be set. Unused axes will remain at its actual values. Could be zero and coords set to nullptr, then actual values of all the axes are used.
coordsCoordinates 0 - X, 1 - Y, 2 - Z, 3 - C, 4 - B, 5 - U, 6 - V, 7 - W, 8 - A, 9 - O

◆ ToolChainCore_StopCNCEx()

TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_StopCNCEx ( int32_t  intIdx,
TGM_LPCSTR  strAddCode 
)

Stops motion or connecting (break).

After stopping it sends the defined G-code (only M function), unless backward move (32) or running without M functions (31) is in process. The sending can only be cancelled only by function ToolChainCore_ResetCNC. After that the process can go on, i.e. ToolChainCore_StartCNCEx or finish by ToolChainCore_ResetCNC functions or connect to a trajectory by ToolChainCore_ConnectCNCEx_Plane.

Returns
Error code Description
-1 Machine not in motion, the function has no sense
-2 intIdx parameter out of range (must be 0-2 on PC, only 0 on TGMmini)
0 success
Parameters
intIdxCore index (0-2 on PC, 0 on TGMmini)
strAddCodePointer to the text of G-code (ANSI string) that will be sent after machine stops. Only M functions are sent, G-functions are ignored. Can be nullptr, then no additional M funcions are sent.

◆ ToolChainCore_ConnectCNCEx_Plane()

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.

Returns
Error code Description
-1 Invalid parameter coords or calling is impossible in the given status, e.g. compilation is running or machine is moving
-2 intIdx parameter out of range (must be 0-2 on PC, only 0 on TGMmini)
0 success
Parameters
intIdxCore index (0-2 on PC, 0 on TGMmini)
nTypeconnection type (see also enum connect_type)
  • 0 Go to the nearest point of trajectory from the coords coordinates and stop
  • 1 Go to G-code line, line no. is in coords[0], file no. or 0 is in coords[1], goes to the initial point in G-code and stop, the line is set
  • 10 Go to the nearest point of trajectory from the coords and go on in mode 30 (normally forward)
  • 11 Go to G-code line, line no. in coords[0], file no. or 0 is in coords[1], goes to the initial point in G-code and stop, the line is set
  • 20 Go to n-th repeat of specified M function, coords[0] has number of repeats, coords[1] has M function number
  • 21 Go in relatively by n-th repeat of specified M function, coords[0] has number of repeats, coords[1] has M function number
    • If G-code is at the beginning (status = -30), only positive values of repeats can be used (> 0).
    • If G-code is at the end (status = -32), only negative or zero values of repeats can be used (<=0).
    • If G-code is interrupted (status = -31):
      • If the number of repeats is 0, it will find the nearest previous M function with the relevant number (if standing right at the relevant M function, it will stay there).
      • If number of repeats equals +1, it will find the next nearest M function after the G-code line, where the machine is just standing.
      • If number of repeats equals -1, it will first find M function as in the case of 0 repeats and then yet another one preceding.
      • Similarly for higher numbers of repeats.
  • 30 Go to the section specified by means of G-code index (each G and M functions have their unique numbers - G-code index) G-code index is in X. Note: M-6 A G-code function can be used favourably.
  • 40 Go to the nearest point of trajectory from the coords and continues in mode 30 (normally forward), there is no delay between the move onto trajectory and the machining
  • 41 Go to start of G-code line, line no. is on X, file no. or 0 is on Y, goes to the initial point of the part and continue the movement, i.e. there is no delay between the move onto trajectory and the machining
  • 42 Go to end of G-code line, line no. is on X, file no. or 0 is on Y and continues on the trajectory without any delay
nCoordsnumber of coordinates in the coords array (may even be 0 - for the connection type 0 or 10, after that the current machine position will be used)
coordsarray of coordinates. Meaning of the values vary with the type of connection. See enum connect_type.
strAddCodepointer to the G-code text (ANSI string) that will be sent BEFORE the main G-code. All G-functions are ignored in this G-code, only M functions will be sent.
bitCodedAxesForCalcbit coded value for connection distance calculation, maximum of three axes is allowed, if more, the first three set will be used.
  • Bit order of axes: X 0x1 Y 0x2 Z 0x4 C 0x8 B 0x10 U 0x20 V 0x40 W 0x80 A 0x100 O 0x200
  • Can be zero, then all axes are taken into account during the calculation. Calculation is done incrementaly in planes XY, XZ, XC, XB, XU, XV, XW, XA, XO.
  • If two bits are set, the calculation is done in the given plane. If the plane of the G2/G3 functions match the plane of the calculation (G17 - XY, G18 - XZ, G19 - YZ), distance of point to arc is calculated, otherwise the G2/G3 is viewed as a line.
  • If three bits are set, the calculation is done in a cartesian space of the given axes. G2/G3 are calculated as arcs only if the first two bits represents the plane of the arc and there is no movement in the third axis (i.e. no screw movement).
  • For complicated movements within n-dimensional space it is better not to use G2/G3 and compose the movement from a series of short G1 lines.
bitCodedAxesForConnectDetermines which axes are moved to the connection point after the calculations.
  • If zero, then up to the number of used axes (the value nCoords for connection types 0, 10, 40, other types can select the number of movement axes in coords[2])
  • If any bit is set, then the according axis will be moved to the connection point. To move all the 10 axes (which is recommended), use the value 0x3FF here.
trajectoryStateAfterConnectif zero, the state will be set automatically (either on trajectory or out of trajectory), otherwise determines the CNC status after connect. Use with care, if the status is wrong after connection, the system may not start movement.
The value of 0 is recommended.

◆ ToolChainCore_GoToPosition()

TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_GoToPosition ( int32_t  intIdx,
const uint32_t  nCoords,
const double *  coords 
)

Manual control.

Moves axes to desired position. Movement parameters (speed + acceleration) are defined using ToolChainCore_SetGCodeParameters

Returns
Error code Description
-1 Error - machine is in motion
-2 intIdx parameter out of range (must be 0-2 on PC, only 0 on TGMmini)
0 success
Parameters
intIdxcore index (0-2 on PC, 0 on TGMmini)
nCoordsnumber of coordinates in the coords array
coordswanted coordinates 0 - X, 1 - Y, 2 - Z, 3 - C, 4 - B, 5 - U, 6 - V, 7 - W, 8 - A, 9 - O

◆ ToolChainCore_GoToPositionEx()

TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_GoToPositionEx ( int32_t  intIdx,
const SIMPLE_GM_PARAMS_WIN32 pDest 
)

Extended manual control.

Moves axes to desired position by linear or arc movement.

Returns
Error code Description
-1 Error - machine is in motion
-2 intIdx parameter out of range (must be 0-2 on PC, only 0 on TGMmini)
0 success
Parameters
intIdxcore index (0-2 on PC, 0 on TGMmini)
pDestspecifies end position, type of trajectory and optional feed. The following fields of the SIMPLE_GM_PARAMS_WIN32 structure are used:

◆ ToolChainCore_MFunc()

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.

Invoke PLC's M function. The interpolator must be in a stop state. Application must wait for M function finish by reading INTERPOLATOR::M_Func variable.

Returns
Error code Description
-1 Error - machine is in motion or previous M function is pending
-2 intIdx parameter out of range (must be 0-2 on PC, only 0 on TGMmini)
0 success
Parameters
intIdxcore index (0-2 on PC, 0 on TGMmini)
funFunction number to be used. Only SIMPLE_GM_PARAMS_WIN32::m_func field is used (M function number).
bDirectToPLCreserved, now internally set to 1 (i.e. the M fucntion is always directly signalized to PLC)

◆ ToolChainCore_FileToIdx()

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.

When using CNC module in real-time TGMotion, maximal number is 16. The inverse function is ToolChainCore_IdxToFile. Length of filename must be less than 252 characters.

Returns
Positive value for existing files, negative value for special types:
fileName returned value
"__unknown__" -1
"__end__" -2
"__stop__" -3
"__exec__" -4
Parameters
intIdxcore index (0-2 on PC, 0 on TGMmini)
fileNamecomplete path to file. UNICODE on PC, ANSI on TGMmini

◆ ToolChainCore_IdxToFile()

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).

Returns
Filename or special text for special numbers. For non-existent number it returns "__unknown__"
fileIdx returned string
-1 "__unknown__"
-2 "__end__"
-3 "__stop__"
-4 "__exec__"
Parameters
intIdxcore index (0-2 on PC, 0 on TGMmini)
fileIdxFile name index (e.g. from SIMPLE_GM_PARAMS_WIN32 structure)

◆ ToolChainCore_SetRelFeed()

TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_SetRelFeed ( int32_t  intIdx,
double  relFeed 
)

Sets the feed override (relative speed).

Returns
Error code Description
-2 intIdx parameter out of range (must be 0-2 on PC, only 0 on TGMmini)
0 success
Parameters
intIdxcore index (0-2 on PC, 0 on TGMmini)
relFeedRelative feed value in range 0.001 - 2.0. (i.e. 0.1 % - 200 %). Invalid values are rounded to above boundaries.

◆ ToolChainCore_SetCallBack()

TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_SetCallBack ( int32_t  intIdx,
int32_t  fceNo,
intptr_t  dwUserData,
FuncPrototype funcPtr 
)

Sets callback function.

Callbacks are way of reverse communication from CNC module back to application. Some callbacks are available only in LOCAL_CORE_MODE_DLL (see DLL_INIT_STRUCT). The list of all availabel callback function is here.

Returns
Error code Description
-1 invalid fceNo value
-2 intIdx parameter out of range (must be 0-2 on PC, only 0 on TGMmini)
0 callback function set
Parameters
intIdxcore index (0-2 on PC, 0 on TGMmini)
fceNocallback function number
dwUserDataany user value which will be passed to the callback function
funcPtrpointer to function (casted to general function prototype)
Note
For functions with fceNo greater than 1000 (APP_MaxFuncNumber) the ToolChainCore_SetCallBack function only can be called after ToolChainCore_LoadFromIni.

◆ ToolChainCore_GetLastError()

TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_GetLastError ( int32_t  intIdx,
CALLBACK_INFO pLastErrorInfo 
)

Returns the last error, if any.

There is also possibility to register callback function DispAndLocateErrorFunc for immediate notify of an error.

Returns
Last error code
Error code Description
-1 invalid parameter lastErrorInfo
-2 intIdx parameter out of range (must be 0-2 on PC, only 0 on TGMmini)
0 success (there was no error, compilation or runtime - members of pLastErrorInfo structure are not set)
1 xexec error (runtime error)
2 xbreak error (interruption by user)
Parameters
intIdxcore index (0-2 on PC, 0 on TGMmini)
pLastErrorInfoPointer to structure CALLBACK_INFO with returned error information (for return values 1 or 2)

◆ ToolChainCore_SetBreakpoint()

TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_SetBreakpoint ( int32_t  intIdx,
uint32_t  editorLine,
int32_t  fileIdx 
)

Set breakpoint in the G-code.

The run stops just BEFORE the G-code part on the gived editor line

Returns
Error code Description
-2 intIdx parameter out of range (must be 0-2 on PC, only 0 on TGMmini)
0 success
Parameters
intIdxcore index (0-2 on PC, 0 on TGMmini)
editorLineLine number, execution stops before this line
fileIdxFile index, can be get by ToolChainCore_FileToIdx

◆ ToolChainCore_GetGCodeSizeInfo()

TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_GetGCodeSizeInfo ( int32_t  intIdx,
GCODE_INFO pInfo 
)

Identifies size (dimension) of G-code.

Returns
Error code Description
-1 invalid parameter pInfo
-2 intIdx parameter out of range (must be 0-2 on PC, only 0 on TGMmini)
0 OK
Parameters
intIdxcore index (0-2 on PC, 0 on TGMmini)
pInfopointer to GCODE_INFO, which will be filled with the size values

◆ ToolChainCore_GetStructuresSize()

TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_GetStructuresSize ( int32_t  intIdx,
uint32_t  nItems,
uint32_t *  items 
)

Returns bytes sizes of internal structures.

Relevant to checking of DLL versions and the main application.

Returns
Always 0
Parameters
intIdxcore index (0-2 on PC, 0 on TGMmini)
nItemsnumber of items in items array, in the range 1 - 7.
itemspointer to array filled with following values:
Index Description
0 maximal number of checked arrays, up to now 7, could be increased in the future
1 size of GCODE_PARAMETERS
2 size of SIMPLE_GM_PARAMS_WIN32
3 size of GM_PARAMS_ENHANCED
4 size of CALLBACK_INFO
5 size of GCODE_INFO
6 size of INTERPOLATOR_MONITOR_SHARED_MEMORY (not yet used)
7 size of MACHINE_PARAMETERS

◆ ToolChainCore_GetVersionString()

TOOLCHAIN_DLL_EXPORT TGM_LPCTSTR TOOLCHAIN_CALLTYPE ToolChainCore_GetVersionString ( int32_t  intIdx)

Returns the DLLs version number and the date and time of compilation.

Returns
UNICODE (PC) or ANSI (TGMmini) string
Parameters
intIdxcore index (0-2 on PC, 0 on TGMmini) - ignored in this function

◆ ToolChainCore_GetMachineParameters()

TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_GetMachineParameters ( int32_t  intIdx,
MACHINE_PARAMETERS pParameters 
)

Returns actual values of MACHINE_PARAMETERS.

Returns
Error code Description
-2 intIdx parameter out of range (must be 0-2 on PC, only 0 on TGMmini)
-1 timeout
0 success
Parameters
intIdxcore index (0-2 on PC, 0 on TGMmini)
pParameterspointer to MACHINE_PARAMETERS structure, will be filled with actual values
Note
This function can be called at any time (i.e. during any CNC status)

◆ ToolChainCore_SetMachineParameters()

TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE ToolChainCore_SetMachineParameters ( int32_t  intIdx,
const MACHINE_PARAMETERS pParameters 
)

Sets new values of MACHINE_PARAMETERS.

Returns
Error code Description
-2 intIdx parameter out of range (must be 0-2 on PC, only 0 on TGMmini)
-1 timeout
0 success
Parameters
intIdxcore index (0-2 on PC, 0 on TGMmini)
pParameterspointer to MACHINE_PARAMETERS structure with new values
Note
This function can be called at any CNC status, but it is highly recommended to call it only when the machine is in stop or trajectory break state.

◆ ToolChainCore_LoadCNCCalcPlugIn()

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)

After successful call of this function, the CNC status is set to cnc_status::statusINVALID and the G-code must be loaded again.

Parameters
fileNameComplete path of the plug-in file (.DLL or .so). If empty null-terminated string, unloads the plug-in.
loadFlagsAdditional load flags:
Value Description
0 load plug-in to both DLL and TGMmotion (real-time)
1 load plug-in to DLL engine only (see also DLL_INIT_STRUCT::Local_Core_Mode and LOCAL_CORE_MODE_DLL)
2 load plug-in to TGMmotion engine only (LOCAL_CORE_MODE_TGM)
userValueThis value will be copied to CNC_CALC_INIT_DATA::userValue. Application can store here any value, pointer, etc. During call of CNC_Calc_Load function, the CNC Calc plugin can store this value and use it for any purpose.
Returns
Error code Description
-1 Any error. See note below.
1 Success
Note
The function cannot be called in the following statuses (returns error): cnc_status::statusCOMPILING, cnc_status::statusSIMULATING, cnc_status::statusSIMULATION_BREAK, cnc_status::statusTEST, cnc_status::statusTEST_BREAK, cnc_status::statusTRAJECTORY_BREAK, cnc_status::statusTRAJECTORY_BREAK_M0, cnc_status::statusFORWARD, cnc_status::statusFORWARD_NO_MFUNC, cnc_status::statusBACKWARD, cnc_status::statusFORWARD_SKIP_FIRST_M, cnc_status::statusCONNECTING, cnc_status::statusCONNECT_MOVE, cnc_status::statusHAND_MOVE, cnc_status::statusCALCULATING, cnc_status::statusSTART_M_FUNCS, cnc_status::statusSTOP_M_FUNCS, cnc_status::statusCONNECT_INS_M_FUNCS