TG Motion  version 502 - 4034/906 cnc 126
Exported functions

Functions

int32_t ToolChainCore_Init (const cnc::DLL_INIT_STRUCT *pInitValues)
 Init the CNC module. More...
 
int32_t ToolChainCore_LoadFromIni (uint32_t intIdx, TGM_LPCTSTR iniFile, uint32_t *pnMaxCores)
 Loads DLL chain from INI file. More...
 
int32_t ToolChainCore_DestroyCNC (uint32_t intIdx)
 Finishes work with DLLs and frees all the allocated memory. More...
 
int32_t ToolChainCore_SetGCodeParameters (uint32_t intIdx, const cnc::GCODE_PARAMETERS *params)
 Sets parameters (properties) of G-code. More...
 
int32_t ToolChainCore_GetGCodeParameters (uint32_t intIdx, cnc::GCODE_PARAMETERS *params)
 Obtains values set with ToolChainCore_SetGCodeParameters, or read from .INI file during startup. More...
 
cnc::cnc_status ToolChainCore_StatusCNC (uint32_t intIdx)
 Actual CNC module state. More...
 
int32_t ToolChainCore_GetPosEx (uint32_t intIdx, int32_t reserved, cnc::ACTUAL_GM_VALUES *pos)
 Returns current position of machine axes together with additional informations. More...
 
int32_t ToolChainCore_CompileFromFile (uint32_t intIdx, TGM_LPCTSTR fileName)
 Compiles G-code from file. More...
 
int32_t ToolChainCore_CompileFromMemory (uint32_t intIdx, TGM_LPCTSTR fileName, TGM_LPCSTR mainCode)
 Compiles G-code from string in memory. More...
 
int32_t ToolChainCore_IsBusy (uint32_t intIdx)
 Checks if the machine is executing G-code. More...
 
int32_t ToolChainCore_StartCNCEx (uint32_t intIdx, cnc::cnc_status regime, TGM_LPCSTR strAddGCode)
 Start or continue G-code. More...
 
int32_t ToolChainCore_ResetCNC (uint32_t intIdx, int32_t regime, const uint32_t nCoords, const float64_t *coords)
 Sets the initial position for G-code. More...
 
int32_t ToolChainCore_StopCNCEx (uint32_t intIdx, TGM_LPCSTR strAddCode)
 Stops motion or connecting (break). More...
 
int32_t ToolChainCore_ConnectCNCEx_Plane (uint32_t intIdx, cnc::connect_type nType, const uint32_t nCoords, const float64_t *coords, TGM_LPCSTR strAddCode, uint32_t bitCodedAxesForCalc, uint32_t bitCodedAxesForConnect, cnc::status_after_connect trajectoryStateAfterConnectRequest)
 Move to the nearest point of trajectory of G-code with possibility of M function insertion after the connection movement. More...
 
int32_t ToolChainCore_GoToPosition (uint32_t intIdx, const uint32_t nCoords, const float64_t *coords)
 Manual control. More...
 
int32_t ToolChainCore_GoToPositionEx (uint32_t intIdx, const cnc::SIMPLE_GM_PARAMS_WIN32 *pDest)
 Extended manual control. More...
 
int32_t ToolChainCore_MFunc (uint32_t intIdx, const cnc::SIMPLE_GM_PARAMS_WIN32 &fun, int32_t bDirectToPLC)
 Send M function directly to system. More...
 
int32_t ToolChainCore_FileToIdx (uint32_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...
 
TGM_LPCTSTR ToolChainCore_IdxToFile (uint32_t intIdx, int32_t fileIdx)
 Returns the complete filename of file with relevant number (index). More...
 
int32_t ToolChainCore_SetRelFeed (uint32_t intIdx, float64_t relFeed)
 Sets the feed override (relative speed). More...
 
int32_t ToolChainCore_SetCallBack (uint32_t intIdx, uint32_t fceNo, intptr_t dwUserData, cnc::FuncPrototype *funcPtr)
 Sets callback function. More...
 
int32_t ToolChainCore_GetLastError (uint32_t intIdx, cnc::CALLBACK_INFO *pLastErrorInfo)
 Returns the last error, if any. More...
 
int32_t ToolChainCore_SetBreakpoint (uint32_t intIdx, uint32_t editorLine, int32_t fileIdx)
 Set breakpoint in the G-code. More...
 
int32_t ToolChainCore_GetGCodeSizeInfo (uint32_t intIdx, cnc::GCODE_INFO *pInfo)
 Identifies size (dimension) of G-code. More...
 
int32_t ToolChainCore_GetStructuresSize (uint32_t intIdx, uint32_t nItems, uint32_t *items)
 Returns bytes sizes of internal structures. More...
 
TGM_LPCTSTR ToolChainCore_GetVersionString (uint32_t intIdx)
 Returns the DLLs version number and the date and time of compilation. More...
 
int32_t ToolChainCore_GetMachineParameters (uint32_t intIdx, cnc::MACHINE_PARAMETERS *pParameters)
 Returns actual values of MACHINE_PARAMETERS. More...
 
int32_t ToolChainCore_SetMachineParameters (uint32_t intIdx, const cnc::MACHINE_PARAMETERS *pParameters)
 Sets new values of MACHINE_PARAMETERS. More...
 
int32_t ToolChainCore_LoadCNCCalcPlugIn (TGM_LPCTSTR fileName, uint32_t loadFlags, int64_t userValue)
 Load CNC Calc plugin (see CNC Calc plug-in exported functions) More...
 
void ToolChain_FlushLogFile ()
 Flush (force to write to disk) the log file.
 
void ToolChain_LogANSI (TGM_LPCSTR info)
 Append the string to the log file. More...
 
int32_t ToolChainCore_SetUserParams (uint32_t intIdx, const float64_t *userParams, uint32_t userParamsCount)
 Set parameters P00 - P99 for use in G-code. More...
 
int32_t ToolChainCore_GCodePrefixPostfix (uint32_t intIdx, TGM_LPCSTR strPrefix, TGM_LPCSTR strPostfix)
 
float64_t ToolChainCore_GetGCodeRunTime (uint32_t intIdx, int32_t fileIdx)
 
int32_t ToolChainCore_SetGCodeRunTime (uint32_t intIdx, int32_t fileIdx, float64_t timeInS)
 Set runtime of the G code. More...
 
int32_t ToolChainCore_ResetStatusCNC (uint32_t intIdx, cnc::reset_status_cnc mode)
 Enables to clear the memory or set the status to out of trajectory. More...
 
int32_t ToolChainCore_SetLogValue (uint32_t logValue) noexcept
 Set new log value directly to CNC module. More...
 
uint32_t ToolChainCore_GetLogValue () noexcept
 Get actual log value set by INI file or by ToolChainCore_SetLogValue() More...
 

Detailed Description

The following functions are exported from SF_TCh_5.dll or libSF_TCh_5.so dynamic libraries.

Function Documentation

◆ ToolChain_LogANSI()

void ToolChain_LogANSI ( TGM_LPCSTR  info)

Append the string to the log file.

Parameters
infoString to be added, always ANSI

◆ ToolChainCore_CompileFromFile()

int32_t ToolChainCore_CompileFromFile ( uint32_t  intIdx,
TGM_LPCTSTR  fileName 
)

Compiles G-code from file.

Returns
Error code Description
-1 bad parameter fileName or compilation is in progress
-2 intIdx parameter out of range (must be 0-2 on PC, only 0-1 on TGMmini)
0 success
Parameters
intIdxCore index (0-2 on PC, 0-1 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()

int32_t ToolChainCore_CompileFromMemory ( uint32_t  intIdx,
TGM_LPCTSTR  fileName,
TGM_LPCSTR  mainCode 
)

Compiles G-code from string in memory.

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

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_ConnectCNCEx_Plane()

int32_t ToolChainCore_ConnectCNCEx_Plane ( uint32_t  intIdx,
cnc::connect_type  nType,
const uint32_t  nCoords,
const float64_t *  coords,
TGM_LPCSTR  strAddCode,
uint32_t  bitCodedAxesForCalc,
uint32_t  bitCodedAxesForConnect,
cnc::status_after_connect  trajectoryStateAfterConnectRequest 
)

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-1 on TGMmini)
0 success
Parameters
intIdxCore index (0-2 on PC, 0-1 on TGMmini)
nTypeconnection type (see also enum cnc::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 begin of part specified by G-code index (each G and M functions have their unique numbers - G-code index).
    • coords[0]: G-code index
    • coords[1]: maximal number of axes which will be moved to starting point of the G-code part.
  • 31 Go to the nearest point of part specified by G-code index.
    • coords[0]: G-code index
    • coords[1]: maximal number of axes which will be moved to starting point of the G-code part.
  • 32 Go to the end of part specified by G-code index.
    • coords[0]: G-code index
    • coords[1]: maximal number of axes which will be moved to starting point of the G-code part.
  • 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
  • 44 Go to the nearest point of the G-code part determined by its G-code index. After the movement to the connection point the execution of the G-code parts continues immediately.
    • coords[0]: G-code index
    • coords[1]: maximal number of axes which will be moved to starting point of the G-code part.
  • 46 Go to the exact point on trajectory given by coords and G-code index and continue movement.
    • coords[0 .. 9]: Point which must lie on the trajectory (0 - X pos, 1 - Y, 2 - Z, 3 - C, 4 - B, 5 - U, 6 - V, 7 - W, 8 - A, 9 - O)
    • coords[10]: G-code index of the part to connect
nCoordsnumber of coordinates in the coords array (may 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 cnc::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. Can be nullptr or empty string.
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 incrementally 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.
trajectoryStateAfterConnectRequestif zero, the state will be set automatically (either on trajectory or out of trajectory), if set to 2, the status out of trajectory will be reported. Other values are invalid, and the function returns an error without performing any action.

◆ ToolChainCore_DestroyCNC()

int32_t ToolChainCore_DestroyCNC ( uint32_t  intIdx)

Finishes work with DLLs and frees all the allocated memory.

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-1 on TGMmini)

◆ ToolChainCore_FileToIdx()

int32_t ToolChainCore_FileToIdx ( uint32_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-1 on TGMmini)
fileNamecomplete path to file. UNICODE on PC, ANSI on TGMmini

◆ ToolChainCore_GCodePrefixPostfix()

int32_t ToolChainCore_GCodePrefixPostfix ( uint32_t  intIdx,
TGM_LPCSTR  strPrefix,
TGM_LPCSTR  strPostfix 
)
Parameters
intIdx
strPrefix
strPostfix
Returns
TOOLCHAIN_DLL_EXPORT int32_t TOOLCHAIN_CALLTYPE

◆ ToolChainCore_GetGCodeParameters()

int32_t ToolChainCore_GetGCodeParameters ( uint32_t  intIdx,
cnc::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-1 on TGMmini)
paramsPointer to cnc::GCODE_PARAMETERS structure, which will be filled with set values

◆ ToolChainCore_GetGCodeRunTime()

float64_t ToolChainCore_GetGCodeRunTime ( uint32_t  intIdx,
int32_t  fileIdx 
)
Parameters
intIdx
fileIdx
Returns

◆ ToolChainCore_GetGCodeSizeInfo()

int32_t ToolChainCore_GetGCodeSizeInfo ( uint32_t  intIdx,
cnc::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-1 on TGMmini)
0 OK
Parameters
intIdxcore index (0-2 on PC, 0-1 on TGMmini)
pInfopointer to cnc::GCODE_INFO, which will be filled with the size values

◆ ToolChainCore_GetLastError()

int32_t ToolChainCore_GetLastError ( uint32_t  intIdx,
cnc::CALLBACK_INFO pLastErrorInfo 
)

Returns the last error, if any.

There is also possibility to register callback function cnc::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-1 on TGMmini)
0 success (there was no error, compilation or runtime - members of pLastErrorInfo structure are not set)
1 xexec error (runtime error)
Parameters
intIdxcore index (0-2 on PC, 0-1 on TGMmini)
pLastErrorInfoPointer to structure cnc::CALLBACK_INFO with returned error information (for return values 1 or 2)

◆ ToolChainCore_GetLogValue()

uint32_t ToolChainCore_GetLogValue ( )
noexcept

Get actual log value set by INI file or by ToolChainCore_SetLogValue()

Returns
Actual log value

◆ ToolChainCore_GetMachineParameters()

int32_t ToolChainCore_GetMachineParameters ( uint32_t  intIdx,
cnc::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-1 on TGMmini)
-1 timeout
0 success
Parameters
intIdxcore index (0-2 on PC, 0-1 on TGMmini)
pParameterspointer to cnc::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_GetPosEx()

int32_t ToolChainCore_GetPosEx ( uint32_t  intIdx,
int32_t  reserved,
cnc::ACTUAL_GM_VALUES pos 
)

Returns current position of machine axes together with additional informations.

Returns
Error code Description
-1 parameter pos is nullptr
-2 intIdx parameter out of range (must be 0-2 on PC, only 0-1 on TGMmini)
0 success
Parameters
intIdxCore index (0-2 on PC, 0-1 on TGMmini)
reservedNot used
posPointer to cnc::ACTUAL_GM_VALUES structure which will be filled with actual values.

◆ ToolChainCore_GetStructuresSize()

int32_t ToolChainCore_GetStructuresSize ( uint32_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-1 on TGMmini) - not used here
nItemsnumber of items in items array, in the range 1 - 8.
itemspointer to array filled with following values:
Index Description
0 maximal number of checked arrays, up to now 8, could be increased in the future
1 size of cnc::GCODE_PARAMETERS
2 size of cnc::SIMPLE_GM_PARAMS_WIN32
3 size of cnc::ACTUAL_GM_VALUES
4 size of cnc::CALLBACK_INFO
5 size of cnc::GCODE_INFO
6 size of cnc::MACHINE_STATUS
7 size of cnc::MACHINE_PARAMETERS
8 size of cnc::DLL_INIT_STRUCT

◆ ToolChainCore_GetVersionString()

TGM_LPCTSTR ToolChainCore_GetVersionString ( uint32_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-1 on TGMmini) - ignored in this function

◆ ToolChainCore_GoToPosition()

int32_t ToolChainCore_GoToPosition ( uint32_t  intIdx,
const uint32_t  nCoords,
const float64_t *  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-1 on TGMmini)
0 success
Parameters
intIdxcore index (0-2 on PC, 0-1 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()

int32_t ToolChainCore_GoToPositionEx ( uint32_t  intIdx,
const cnc::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-1 on TGMmini)
0 success
Parameters
intIdxcore index (0-2 on PC, 0-1 on TGMmini)
pDestspecifies end position, type of trajectory and optional feed. The following fields of the cnc::SIMPLE_GM_PARAMS_WIN32 structure are used:

◆ ToolChainCore_IdxToFile()

TGM_LPCTSTR ToolChainCore_IdxToFile ( uint32_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-1 on TGMmini)
fileIdxFile name index (e.g. from cnc::SIMPLE_GM_PARAMS_WIN32 structure)

◆ ToolChainCore_Init()

int32_t ToolChainCore_Init ( const cnc::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 cnc::DLL_INIT_STRUCT with initialization parameters

◆ ToolChainCore_IsBusy()

int32_t ToolChainCore_IsBusy ( uint32_t  intIdx)

Checks if the machine is executing G-code.

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

◆ ToolChainCore_LoadCNCCalcPlugIn()

int32_t 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::cnc_status::INVALID_00 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.
loadFlagsReserved for future use
userValueThis value will be copied to cnc::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 statuses of positive value (>0).

◆ ToolChainCore_LoadFromIni()

int32_t ToolChainCore_LoadFromIni ( uint32_t  intIdx,
TGM_LPCTSTR  iniFile,
uint32_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-1 on TGMmini)
iniFileFull path of the .INI file
pnMaxCoresPointer to variable which receives 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]
;##########################################################################################
Compiler0=SF_DComp_5
Executor0=SF_DExec_5
Calculator0=SF_XYZMath_5
CNC0=SF_XYZWorker_5
;##########################################################################################
[CNC]
Driver=SF_RTDrv_5

◆ ToolChainCore_MFunc()

int32_t ToolChainCore_MFunc ( uint32_t  intIdx,
const cnc::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-1 on TGMmini)
0 success
Parameters
intIdxcore index (0-2 on PC, 0-1 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_ResetCNC()

int32_t ToolChainCore_ResetCNC ( uint32_t  intIdx,
int32_t  regime,
const uint32_t  nCoords,
const float64_t *  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-1 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-1 on TGMmini)
regime---------— | -----------------— 1 | Only sets initial position for G-code, no setting of coordinates 10 | Setting of coordinates for simulation (not yet implemented) 20 | Setting of coordinates for testing (not yet implemented) 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_ResetStatusCNC()

int32_t ToolChainCore_ResetStatusCNC ( uint32_t  intIdx,
cnc::reset_status_cnc  mode 
)

Enables to clear the memory or set the status to out of trajectory.

Can be called only if CNC status is a negative number.

Parameters
intIdxcore index (0-2 on PC, 0-1 on TGMmini)
modeallowed modes:
Mode Description
0 Removes compiled file, free memory, set the CNC status to cnc::cnc_status::INVALID_00
1 Set the internal status to cnc::cnc_status::OUT_OF_TRAJECTORY_M50
Returns
Error code Description
-2 intIdx parameter out of range (must be 0-2 on PC, only 0-1 on TGMmini)
-1 The CNC module is in motion state
0 success

◆ ToolChainCore_SetBreakpoint()

int32_t ToolChainCore_SetBreakpoint ( uint32_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-1 on TGMmini)
0 success
Parameters
intIdxcore index (0-2 on PC, 0-1 on TGMmini)
editorLineLine number, execution stops before this line
fileIdxFile index, can be get by ToolChainCore_FileToIdx

◆ ToolChainCore_SetCallBack()

int32_t ToolChainCore_SetCallBack ( uint32_t  intIdx,
uint32_t  fceNo,
intptr_t  dwUserData,
cnc::FuncPrototype funcPtr 
)

Sets callback function.

Callbacks are way of reverse communication from CNC module back to application. The list of all available 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-1 on TGMmini)
0 callback function set
Parameters
intIdxcore index (0-2 on PC, 0-1 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_SetGCodeParameters()

int32_t ToolChainCore_SetGCodeParameters ( uint32_t  intIdx,
const cnc::GCODE_PARAMETERS params 
)

Sets parameters (properties) of G-code.

Calling is possible also during G-code interruption ToolChainCore_StopCNCEx, but only some fields of cnc::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 changed at this moment (machine is in motion)
0 success
Parameters
intIdxCore index (0-2 on PC, 0-1 on TGMmini)
paramsPointer to cnc::GCODE_PARAMETERS structure with desired parameters

◆ ToolChainCore_SetGCodeRunTime()

int32_t ToolChainCore_SetGCodeRunTime ( uint32_t  intIdx,
int32_t  fileIdx,
float64_t  timeInS 
)

Set runtime of the G code.

Parameters
intIdx
fileIdx
timeInS
Returns

◆ ToolChainCore_SetLogValue()

int32_t ToolChainCore_SetLogValue ( uint32_t  logValue)
noexcept

Set new log value directly to CNC module.

Parameters
logValuebit-coded value to set what information is logged and where. Bits can be anyhow combined. At least on of the Output bit (see the table) must be set to produce any output. The logging is common for all the CNC cores.
Bit value Description
0x00000001 Debug mode - generates helper debug files to analyze G-code processing
0x00000002 Verbose - increases number of information sent to Log and/or debug files
0x00000004 Worker - info from SF_XYZWorker_5 library
0x00000008 ToolChain - info from the main SF_TCh_5 library
0x00000010 Driver - info from the SF_RTDrv_5 library
0x00000020 Compiler - info from G-code analyzer and compiler SF_DComp_5 library
0x00000040 Exec - info from executor SF_DExec_5 library
0x00000080 Math - info from tool compensation calculator SF_XYZMath_5 library
0x10000000 Output to DebugView - send information to DbgView (Windows) or console (Linux)
0x20000000 Output to File - send information to log file (usually in log subdirectory)
0x40000000 Output to TGMotion - send information to TGMotion Debug Console
Returns
Always success
Note
This function can be called at any time from any thread.
Logging in principle slows down the G-code processing and runtime and should be enabled for diagnostics purposes only.

◆ ToolChainCore_SetMachineParameters()

int32_t ToolChainCore_SetMachineParameters ( uint32_t  intIdx,
const cnc::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-1 on TGMmini)
-1 timeout
0 success
Parameters
intIdxcore index (0-2 on PC, 0-1 on TGMmini)
pParameterspointer to cnc::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_SetRelFeed()

int32_t ToolChainCore_SetRelFeed ( uint32_t  intIdx,
float64_t  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-1 on TGMmini)
0 success
Parameters
intIdxcore index (0-2 on PC, 0-1 on TGMmini)
relFeedRelative feed value in range 0.001 - 2.0. (i.e. 0.1 % - 200 %). Invalid values are rounded to above boundaries.

◆ ToolChainCore_SetUserParams()

int32_t ToolChainCore_SetUserParams ( uint32_t  intIdx,
const float64_t *  userParams,
uint32_t  userParamsCount 
)

Set parameters P00 - P99 for use in G-code.

Parameters
intIdxcore index (0-2 on PC, 0-1 on TGMmini)
userParamsarray of 100 float64_t parameters
userParamsCountmust be 0 - do not use the parameters or 100. Other values are invalid.
Returns

◆ ToolChainCore_StartCNCEx()

int32_t ToolChainCore_StartCNCEx ( uint32_t  intIdx,
cnc::cnc_status  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-1 on TGMmini)
0 success
Parameters
intIdxCore index (0-2 on PC, 0-1 on TGMmini)
regimeStart regime:
Value Description
10 Simulation
20 Test
30 CNC forward
31 CNC forward without M functions with feed defined in cnc::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_StatusCNC()

cnc::cnc_status ToolChainCore_StatusCNC ( uint32_t  intIdx)

Actual CNC module state.

Returns
One of the following value (see also enum cnc::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)
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 CNC status is also returned by ToolChainCore_GetPosEx in the cnc::ACTUAL_GM_VALUES structure, so there is no need to call this function if the ToolChainCore_GetPosEx is used.

◆ ToolChainCore_StopCNCEx()

int32_t ToolChainCore_StopCNCEx ( uint32_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 canceled 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-1 on TGMmini)
0 success
Parameters
intIdxCore index (0-2 on PC, 0-1 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 functions are sent.