TG Motion  version 502 - 4034/906 cnc 126
Application callbacks

Typedefs

typedef int32_t cnc::FuncPrototype(intptr_t dwUserData)
 Generic callback function prototype.
 
typedef int32_t cnc::AddOutputLogFunc(intptr_t dwUserData, uint32_t tab, TGM_LPCTSTR info, CALLBACK_INFO *callBackInfo)
 Writes text to output log. More...
 
typedef int32_t cnc::SetStatusBarTextFunc(intptr_t dwUserData, uint32_t pane, TGM_LPCTSTR strText, CALLBACK_INFO *callBackInfo)
 Display informational text in the status line of the application. More...
 
typedef int32_t cnc::IsDebugModeFunc(intptr_t dwUserData)
 Ask if debug regime is enabled. More...
 
typedef int32_t cnc::IsVerboseModeFunc(intptr_t dwUserData)
 Ask if verbose regime is enabled. More...
 
typedef TGM_LPCTSTR cnc::GetLibPathFunc(intptr_t dwUserData)
 Returns path to external G functions stored as G-code on the disk. More...
 
typedef TGM_LPCTSTR cnc::GetToolPathFunc(intptr_t dwUserData)
 Returns path to files describing tools geometry. Only for lathe. More...
 
typedef TGM_LPCTSTR cnc::GetSystemPathFunc(intptr_t dwUserData)
 Returns path to system files. Not yet used by CNC module. More...
 
typedef int64_t cnc::GetFileTimeStampFunc(intptr_t dwUserData, int32_t fileIdx)
 returns time stamp of a given file (usually time in ms since epoch) More...
 
typedef int32_t cnc::DoYieldFunc(intptr_t dwUserData, int32_t messageOnly)
 Switch control to other thread. LOCAL_CORE_MODE_DLL only. More...
 
typedef void cnc::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 float64_t cnc::ReadIniDoubleFunc(intptr_t dwUserData, TGM_LPCTSTR section, TGM_LPCTSTR key, float64_t defValue)
 Read float64_t value from .INI file. More...
 
typedef int32_t cnc::ReadIniIntFunc(intptr_t dwUserData, TGM_LPCTSTR section, TGM_LPCTSTR key, int32_t defValue)
 Read integer value from .INI file. More...
 
typedef int32_t cnc::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 cnc::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 void cnc::DispRunInfoFunc(intptr_t dwUserData, const SIMPLE_GM_PARAMS_WIN32 *pCmd)
 
typedef int32_t cnc::AddOutputLogWithMsgBoxFunc(intptr_t dwUserData, uint32_t tab, uint32_t buttons, TGM_LPCTSTR info, CALLBACK_INFO *callBackInfo)
 Writes text to output log and optionally displays it in message box dialog panel (OS dependent) More...
 
typedef int32_t cnc::SetStatusBarProgressFunc(intptr_t dwUserData, uint32_t progress)
 Display progress bar. More...
 
typedef int32_t cnc::DriverInitializeFunc(intptr_t dwUserData, float64_t *params, uint32_t nParams, cnc_status nRunMode)
 Called always before G-code execution. More...
 
typedef int32_t cnc::DriverGFunc(intptr_t dwUserData, const SIMPLE_GM_PARAMS_WIN32 *v)
 Called to simulate G function. More...
 
typedef int32_t cnc::DriverMFunc(intptr_t dwUserData, const SIMPLE_GM_PARAMS_WIN32 *v)
 Called to simulate M function. More...
 
typedef int32_t cnc::ConnectPointCalcStartFunc(intptr_t dwUserData, const uint32_t nType, const uint32_t nCoords, const float64_t *coords, const uint32_t bitCodedAxesForCalc)
 Initiate user connection calculation. More...
 
typedef int32_t cnc::ConnectPointCalcFunc(intptr_t dwUserData, const SIMPLE_GM_PARAMS_WIN32 *part, float64_t *calcSquareDistanceFromCoords, P10DOUBLE *calcConnectPoint)
 Calculate distance from initial tool point to a give G-code part. More...
 
typedef int32_t cnc::ConnectPointCalcEndFunc(intptr_t dwUserData, SIMPLE_GM_PARAMS_WIN32 *partToBeConnectedTo, P10DOUBLE *connectPosToBeMovedTo)
 End of connection calculation. More...
 
typedef int32_t cnc::DriverEnd(intptr_t dwUserData)
 Called when the G-code simulation finishes. More...
 
typedef int32_t cnc::MathWarningFunc(intptr_t dwUserData, CALLBACK_INFO *pCallbackInfo)
 Called in case of warning issued during tool diameter compensation calculation. More...
 

Variables

constexpr uint32_t cnc::DEVICE_ERROR_OUT_TAB { 0U }
 add log message to specific log window if possible
 
constexpr uint32_t cnc::CNC_OUT_TAB { 1U }
 add log message to specific log window if possible
 
constexpr uint32_t cnc::M29_OUT_TAB { 2U }
 add log message to specific log window if possible
 
constexpr uint32_t cnc::STATUS_LINE_ONLY { 3U }
 add log message to specific log window if possible
 
constexpr uint32_t cnc::ACTIVATE_TAB { 0x100U }
 activate the selected tab
 
constexpr uint32_t cnc::PREFIX_TIME { 0x200U }
 prefix the message with time
 
constexpr uint32_t cnc::APP_AddOutputLogFunc { 1U }
 callback index number
 
constexpr uint32_t cnc::APP_SetStatusBarTextFunc { 2U }
 callback index number
 
constexpr uint32_t cnc::APP_IsDebugModeFunc { 3U }
 callback index number
 
constexpr uint32_t cnc::APP_IsVerboseModeFunc { 4U }
 callback index number
 
constexpr uint32_t cnc::APP_GetLibPathFunc { 5U }
 callback index number
 
constexpr uint32_t cnc::APP_GetToolPathFunc { 6U }
 callback index number
 
constexpr uint32_t cnc::APP_GetSystemPathFunc { 7U }
 callback index number
 
constexpr uint32_t cnc::APP_GetFileTimeStampFunc { 10U }
 callback index number
 
constexpr uint32_t cnc::APP_DoYieldFunc { 11U }
 callback index number
 
constexpr uint32_t cnc::APP_ReadIniStringFunc { 12U }
 callback index number
 
constexpr uint32_t cnc::APP_ReadIniDoubleFunc { 13U }
 callback index number
 
constexpr uint32_t cnc::APP_ReadIniIntFunc { 14U }
 callback index number
 
constexpr uint32_t cnc::APP_IsBreakpointFunc { 17U }
 callback index number
 
constexpr uint32_t cnc::APP_DispAndLocateErrorFunc { 18U }
 callback index number
 
constexpr uint32_t cnc::APP_DispRunInfo { 19U }
 
constexpr uint32_t cnc::APP_SetStatusBarProgressFunc { 32U }
 callback index number
 
constexpr uint32_t cnc::APP_MaxFuncNumber { 1000U }
 last function in APP group
 
constexpr uint32_t cnc::DRV_InitializeFunc { 1001U }
 callback index number
 
constexpr uint32_t cnc::DRV_GFunc { 1002U }
 callback index number
 
constexpr uint32_t cnc::DRV_MFunc { 1003U }
 callback index number
 
constexpr uint32_t cnc::ConnectPointCalcStartFuncNumber { 1004U }
 callback index number
 
constexpr uint32_t cnc::ConnectPointCalcFunc_UseReturnValues { 1U }
 Return value of ConnectPointCalcFunc or ConnectPointCalcEndFunc values are used.
 
constexpr uint32_t cnc::ConnectPointCalcFuncNumber { 1005U }
 callback index number
 
constexpr uint32_t cnc::ConnectPointCalcEndFuncNumber { 1006U }
 callback index number
 
constexpr uint32_t cnc::DRV_End { 1007U }
 callback index number
 

Detailed Description

Typedef Documentation

◆ AddOutputLogFunc

typedef int32_t cnc::AddOutputLogFunc(intptr_t dwUserData, uint32_t tab, TGM_LPCTSTR info, CALLBACK_INFO *callBackInfo)

Writes text to output log.

Parameters
dwUserDataUser data given by ToolChainCore_SetCallBack function
tabindicates severity of the text. Log output may be directed to:
tab value description
DEVICE_ERROR_OUT_TAB 0 errors tab
CNC_OUT_TAB 1 CNC tab (syntax errors, etc.)
M29_OUT_TAB 2 output of M29 function
STATUS_LINE_ONLY 3 display text only in status line
ACTIVATE_TAB 0x100 activate view
infoText to be displayed
callBackInfoPointer to CALLBACK_INFO with additional text informations
Returns
Always 0, ignored by CNC module

◆ AddOutputLogWithMsgBoxFunc

typedef int32_t cnc::AddOutputLogWithMsgBoxFunc(intptr_t dwUserData, uint32_t tab, uint32_t buttons, TGM_LPCTSTR info, CALLBACK_INFO *callBackInfo)

Writes text to output log and optionally displays it in message box dialog panel (OS dependent)

Parameters
dwUserDataUser data given by ToolChainCore_SetCallBack function
tabindicates severity of the text. Log output may be directed to:
tab value description
DEVICE_ERROR_OUT_TAB 0 errors tab
CNC_OUT_TAB 1 CNC tab (syntax errors, etc.)
M29_OUT_TAB 2 output of M29 function
STATUS_LINE_ONLY 3 display text only in status line
ACTIVATE_TAB 0x100 activate view
buttonsWindows MessageBox buttons constants (IDOK, IDCANCEL, etc...)
infoText to be displayed
callBackInfoPointer to CALLBACK_INFO with additional text informations
Returns
Always Button id clicked by user (IDOK, IDCANCEL, etc...)

◆ ConnectPointCalcEndFunc

typedef int32_t cnc::ConnectPointCalcEndFunc(intptr_t dwUserData, SIMPLE_GM_PARAMS_WIN32 *partToBeConnectedTo, P10DOUBLE *connectPosToBeMovedTo)

End of connection calculation.

The user application can e.g. store all the movement parts passed in the ConnectPointCalcFunc and calculate the final connection point and part during this callback.

Parameters
dwUserDataUser data given by ToolChainCore_SetCallBack function
partToBeConnectedToChosen part of the G-code where the connection shall proceed. The user application can modify this parameter and set to it any other valid part of the G-code.
connectPosToBeMovedToPosition where the tool should go. The point must be on the partToBeConnectedTo.
Returns
Depending on the return value, the system uses or ignores returned params:
Value Description
0 Returned values are ignored
1 The partToBeConnectedTo and connectPosToBeMovedTo contain valid values and will be used

◆ ConnectPointCalcFunc

typedef int32_t cnc::ConnectPointCalcFunc(intptr_t dwUserData, const SIMPLE_GM_PARAMS_WIN32 *part, float64_t *calcSquareDistanceFromCoords, P10DOUBLE *calcConnectPoint)

Calculate distance from initial tool point to a give G-code part.

This callback is periodically called for all the move parts of the G-code (G0, G1, G2, G3). The user application can modify the values calculated by the system. This could be useful for machines with axes which form non-Cartesian space (e.g. some axes are linear, some are rotational).

Parameters
dwUserDataUser data given by ToolChainCore_SetCallBack function
partActual part to be calculated. Input only.
calcSquareDistanceFromCoordsThe system calculates the squared distance from coords to part and gives it in the calcSquareDistanceFromCoords parameter. The callback function can modify this value and return it back. The value could be > 1e38, in that case the distance is larger than the threshold given in cnc::GCODE_PARAMETERS::maxConnectionDistance.
calcConnectPointThe system calculates the point on the part which would be the coordinates where the tool shall go to as a result of the connection (in the case the part is used as the connection part). The callback function can modify this parameter and return back different values. Only nCoords are valid.
Returns
Depending on the return value, the system uses or ignores returned params:
Value Description
0 Returned values are ignored
1 The calculatedDistanceFromCoords and calculatedCrossPoint contain valid values and will be used

◆ ConnectPointCalcStartFunc

typedef int32_t cnc::ConnectPointCalcStartFunc(intptr_t dwUserData, const uint32_t nType, const uint32_t nCoords, const float64_t *coords, const uint32_t bitCodedAxesForCalc)

Initiate user connection calculation.

This function is called at the start of connection calculation. It transfers the parameters given in the ToolChainCore_ConnectCNCEx_Plane function to the user application space.

Parameters
nTypeConnection type (see also enum cnc::connect_type). Only connectBY_COORD (0), connectBY_COORD_GO (10), connectBY_COORD_GO_BUFFERED(40) are used.
dwUserDataUser data given by ToolChainCore_SetCallBack function
nCoordsNumber of valid values in the coords parameter. Input only.
coordsCoordinates of the point from which is the connection function calculated. It is a copy of coords parameter of the ToolChainCore_ConnectCNCEx_Plane function. Input only.
bitCodedAxesForCalcCopy of bitCodedAxesForCalc parameter of the ToolChainCore_ConnectCNCEx_Plane function.
Returns
Always 0, ignored

◆ DispAndLocateErrorFunc

typedef int32_t cnc::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.

Set this callback very early during application startup, preferably before ToolChainCore_LoadFromIni function.

Parameters
dwUserDataUser data given by ToolChainCore_SetCallBack function
editorLineLine of text with error. Could be 0 for some type of errors.
fileIdxIndex of the G-code file with the error. Could be negative for some type of errors.
errStringError text, always in English. Translations to other languages can be made with the help of information given in callBackInfo parameter
callBackInfoPointer to CALLBACK_INFO with additional error information (error number, error arguments, etc...)
Returns
Always 0, ignored

◆ DoYieldFunc

typedef int32_t cnc::DoYieldFunc(intptr_t dwUserData, int32_t messageOnly)

Switch control to other thread. LOCAL_CORE_MODE_DLL only.

Parameters
dwUserDataUser data given by ToolChainCore_SetCallBack function
messageOnlyCan be -1 for all OS messages or a specific message (e.g. WM_TIMER in Windows)
Returns
Always 0, ignored by CNC module
Note
It is not necessary to implement this callback.

◆ DriverEnd

typedef int32_t cnc::DriverEnd(intptr_t dwUserData)

Called when the G-code simulation finishes.

Parameters
dwUserDataUser data given by ToolChainCore_SetCallBack function
Returns
Always 0, ignored

◆ DriverGFunc

typedef int32_t cnc::DriverGFunc(intptr_t dwUserData, const SIMPLE_GM_PARAMS_WIN32 *v)

Called to simulate G function.

Parameters
dwUserDataUser data given by ToolChainCore_SetCallBack function
v| Pointer to SIMPLE_GM_PARAMS_WIN32 with relevant actual G function information
Returns
Always 0, ignored

◆ DriverInitializeFunc

typedef int32_t cnc::DriverInitializeFunc(intptr_t dwUserData, float64_t *params, uint32_t nParams, cnc_status nRunMode)

Called always before G-code execution.

In simulation or test mode (regimes 10 or 20), the driver callbacks are called. With help of these callbacks, complete simulation of G-code can be created in the application. The drive callbacks can be set after the call of ToolChainCore_LoadFromIni function.

Parameters
dwUserDataUser data given by ToolChainCore_SetCallBack function
paramspointer to array of doubles to be filled with desired values
nParamsNumber of items in the array
nRunModeActual run mode
Returns
Always 0, ignored

◆ DriverMFunc

typedef int32_t cnc::DriverMFunc(intptr_t dwUserData, const SIMPLE_GM_PARAMS_WIN32 *v)

Called to simulate M function.

Parameters
dwUserDataUser data given by ToolChainCore_SetCallBack function
v| Pointer to SIMPLE_GM_PARAMS_WIN32 with relevant actual M function information
Note
This callback is usually not implemented, only if the simulation wants to display M functions from code.
Returns
Always 0, ignored

◆ GetFileTimeStampFunc

typedef int64_t cnc::GetFileTimeStampFunc(intptr_t dwUserData, int32_t fileIdx)

returns time stamp of a given file (usually time in ms since epoch)

Parameters
dwUserDataUser data given by ToolChainCore_SetCallBack function
fileIdxIndex of the file. File name and path must be taken by ToolChainCore_IdxToFile.
Returns
64bit time value
Note
It is not necessary to implement this callback.

◆ GetLibPathFunc

typedef TGM_LPCTSTR cnc::GetLibPathFunc(intptr_t dwUserData)

Returns path to external G functions stored as G-code on the disk.

Parameters
dwUserDataUser data given by ToolChainCore_SetCallBack function
Returns
String with full path. UNICODE on PC, ANSI on TGMmini
Note
the path can be also set by ToolChainCore_Init function.

◆ GetSystemPathFunc

typedef TGM_LPCTSTR cnc::GetSystemPathFunc(intptr_t dwUserData)

Returns path to system files. Not yet used by CNC module.

Parameters
dwUserDataUser data given by ToolChainCore_SetCallBack function
Returns
Path as UNICODE on PC or ANSI on TGMmini.
Note
It is not necessary to implement this callback.

◆ GetToolPathFunc

typedef TGM_LPCTSTR cnc::GetToolPathFunc(intptr_t dwUserData)

Returns path to files describing tools geometry. Only for lathe.

Parameters
dwUserDataUser data given by ToolChainCore_SetCallBack function
Returns
Full path to directory with tool description files.
Note
It is not necessary to implement this callback.

◆ IsBreakpointFunc

typedef int32_t cnc::IsBreakpointFunc(intptr_t dwUserData, uint32_t editorLine, int32_t fileIdx)

Determines if there is a breakpoint on given G-code file line.

CNC system has built-in support for exactly one breakpoint. If there is a need for multiple breakpoints, this callback must be implemented.

Parameters
dwUserDataUser data given by ToolChainCore_SetCallBack function
editorLineLine to be checked
fileIdxFile index of the G-code. File name can be get by ToolChainCore_IdxToFile.
Returns
1 if there is a breakpoint on given line and file, otherwise 0

◆ IsDebugModeFunc

typedef int32_t cnc::IsDebugModeFunc(intptr_t dwUserData)

Ask if debug regime is enabled.

Debug regime displays a lot of information to debug view (or terminal), produces helper files (results of compilation and G-code execution) and slow down the whole CNC module. Can be enabled also by .INI file.

Parameters
dwUserDataUser data given by ToolChainCore_SetCallBack function
Returns
1 for debug mode, 0 for normal mode

◆ IsVerboseModeFunc

typedef int32_t cnc::IsVerboseModeFunc(intptr_t dwUserData)

Ask if verbose regime is enabled.

Verbose regime adds additional information to debug mode, displayed in debug output or terminal. Slows down the CNC module significantly (especially for large G-code files) Can be enabled also by .INI file.

Parameters
dwUserDataUser data given by ToolChainCore_SetCallBack function
Returns
1 for verbose mode, 0 for normal mode

◆ MathWarningFunc

typedef int32_t cnc::MathWarningFunc(intptr_t dwUserData, CALLBACK_INFO *pCallbackInfo)

Called in case of warning issued during tool diameter compensation calculation.

Depending on G-code, there could be very large number of calls of this function.

Parameters
dwUserDataUser data given by ToolChainCore_SetCallBack function
pCallbackInfoPointer to CALLBACK_INFO with informations about the warning
Returns
Always 0, ignored

◆ ReadIniDoubleFunc

typedef float64_t cnc::ReadIniDoubleFunc(intptr_t dwUserData, TGM_LPCTSTR section, TGM_LPCTSTR key, float64_t defValue)

Read float64_t value from .INI file.

Follows Windows .INI file syntax.

Parameters
dwUserDataUser data given by ToolChainCore_SetCallBack function
sectionFile section (in square brackets)
keyKey name (text in front of the equal sign)
defValueDefault value if key not found
Returns
Value from the .INI file
Note
It is not necessary to implement this callback.

◆ ReadIniIntFunc

typedef int32_t cnc::ReadIniIntFunc(intptr_t dwUserData, TGM_LPCTSTR section, TGM_LPCTSTR key, int32_t defValue)

Read integer value from .INI file.

Follows Windows .INI file syntax.

Parameters
dwUserDataUser data given by ToolChainCore_SetCallBack function
sectionFile section (in square brackets)
keyKey name (text in front of the equal sign)
defValueDefault value if key not found
Returns
Value from the .INI file
Note
It is not necessary to implement this callback.

◆ ReadIniStringFunc

typedef void cnc::ReadIniStringFunc(intptr_t dwUserData, TGM_LPCTSTR section, TGM_LPCTSTR key, TGM_LPCTSTR defValue, TGM_LPTSTR buffer, uint32_t bufferSizeInCharacters)

Read string from .INI file.

Follows Windows .INI file syntax.

Parameters
dwUserDataUser data given by ToolChainCore_SetCallBack function
sectionFile section (in square brackets)
keyKey name (text in front of the equal sign)
defValueDefault text value if key not found
bufferbuffer where to copy string from .INI file
bufferSizeInCharactersSize of the buffer in characters (not bytes)
Note
It is not necessary to implement this callback.

◆ SetStatusBarProgressFunc

typedef int32_t cnc::SetStatusBarProgressFunc(intptr_t dwUserData, uint32_t progress)

Display progress bar.

Called during long operations like compilation, etc.

Parameters
dwUserDataUser data given by ToolChainCore_SetCallBack function
progressPercentage value of the progress, in the range 0 - 100
Returns
Always 0, ignored by CNC module

◆ SetStatusBarTextFunc

typedef int32_t cnc::SetStatusBarTextFunc(intptr_t dwUserData, uint32_t pane, TGM_LPCTSTR strText, CALLBACK_INFO *callBackInfo)

Display informational text in the status line of the application.

Called during long operations like compilation, etc.

Parameters
dwUserDataUser data given by ToolChainCore_SetCallBack function
panereserved, use always 0
strTextText to be displayed in a status line of the application
callBackInfoPointer to CALLBACK_INFO with additional text information
Returns
Always 0, ignored by CNC module