Development Tools
Development Tools
Function Definition
void opapi_setup(void)
Setup function. Must be present with exactly the same declaration style and name. Called
when OptiPath API library is first loaded. It is to register user's optimization function.
The following functions can be and should only be called in this setup function:
opapi_set_initialize_function(OPAPI_InitializeFunction);
opapi_set_tool_change_setup_function(OPAI_ToolSetupFunction);
opapi_set_optimize_function(OPAPI_OptimizeFunction);
opapi_set_terminate_function(OPAPI_TerminateFunction);
opapi_set_user_data(void *);
void opapi_set_initialize_function(OPAPI_InitializeFunction func_p)
Register user's initialization function with VERICUT. The initialization function
registered, func_p, should have the following declaration style:
typedef int (*OPAPI_InitializeFunction)(void *userData);
which returns 1 if initialization is successful or 0 if initialization failed. If failed, OptiPath
will be turned off. This function should only be called in opapi_setup() function. Once
registered, the initialization function, func_p, will be called each time the user turn
OptiPath on.
void opapi_set_tool_change_setup_function(OPAPI_ToolSetupFunction func_p)
Register user's tool change setup function with VERICUT. The tool change function
registered, func_p, should have the following declaration style:
typedef int (*OPAPI_ToolSetupFunction)(void *userData);
which returns 1 if tool setup is successful or 0 if tool setup failed. If failed, no
optimization will occur for the current tool. Therefore, if a tool does not need to be
optimized, just return 0 when func_p is called for this tool. This function should only be
called in opapi_setup() function. Once registered, the tool setup function, func_p, will be
called each time a tool change occurs.
void opapi_set_optimize_function(OPAPI_OptimizeFunction func_p)
Register user's optimization function with VERICUT. The optimization function
registered, func_p, should have the following declaration style:
typedef void (*OPAPI_OptimizeFunction)(void *userData);
double opapi_get_radial_width(void)
Return maximum radial width.
double opapi_get_axial_depth(void)
Return maximum axial depth.
double opapi_get_chip_thickness(void)
Return chip thickness.
double opapi_get_volume_removed(void)
Return volume of material being removed by current motion.
double opapi_get_program_feedrate(void)
Return programmed feedrate.
double opapi_get_program_spindle_speed(void)
Return program spindle speed in rpm.
double opapi_get_spindle_speed(void)
Return spindle speed in rpm.
double opapi_get_total_time(void)
Return total time.
double opapi_get_total_distance(void)
Return total distance.
double opapi_get_total_volume_removed(void)
Return total volume of material being removed.
int opapi_get_conventional_cut_flag(void)
Return conventional cut flag.
int opapi_get_side_cut_flag(void)
Return side cut flag.
int opapi_get_thin_cut_flag(void)
Return thin cut flag.
char * opapi_get_variable_value(char * variable_name)
Return a variable value. Only valid for G-code toolpath file.
Parameters:
variable_name: Input, name of the variable.
8
10
11
/*********************************************************
This function shall perform a TNC disconnect, un-initialize the COM interface and reset
session variables.
Returns:
0, Error
1, OK
**********************************************************/
int ctlapi_hard_terminate_TNC(void);
/*********************************************************
This function shall set the main program file, set tool position, set feed rate and set
execution mode. This function will be called for initial setting of main program file, for
main program file change and at simulation reset.
(I) program, main program file
12
/*********************************************************
This function shall start the execution of the selected main program file.
Returns:
0, Error
1, OK
**********************************************************/
int ctlapi_start_program_TNC(void);
/*********************************************************
This function shall stop execution of the main program file.
Returns:
0, Error
1, OK
**********************************************************/
int ctlapi_stop_program_TNC(void);
13
/*********************************************************
This function shall get the list of motions created from one record.
(O) list, list of motions created from one record.
Returns:
number of motions (int)
**********************************************************/
int ctlapi_get_next_record_TNC(sCTL_MOTION **list);
/*********************************************************
This function shall open the tool file for write. The tool file should be located in the same
directory as the Main Program File (MPF). Extract the path from the specified MPF and
construct the tool file (path and name.)
(I) mpf, main program file
Returns:
0, Error
1, OK
**********************************************************/
int ctlapi_frame_initialize_TNC(char *mpf);
14
/*********************************************************
This function shall write tool info to the tool file for a single tool.
(I) tool_num, tool number
(I) radius, tool radius
(I) length, tool length
Returns:
0, Error
1, OK
**********************************************************/
int ctlapi_frame_tool_TNC(int tool_num, double radius, double length);
/*********************************************************
15
/*********************************************************
This function shall return the program-at-end flag.
Returns:
0, not at end of program
1, at end of program
**********************************************************/
int ctlapi_get_prog_at_end_TNC(void);
/*********************************************************
This function shall set the event notify function.
The event notify function shall notify VERICUT of one of the following events:
0 = program block
1 = tool change
2 = enter subroutine
3 = leave subroutine
16
/*********************************************************
This function shall set the client message function.
The client message function allows the controller to pass text messages to VERICUT.
The client message function prototype is:
void client_message(char *message);
(I) func, client message function.
Returns:
none
17
18