This section describes the basic process for developing an Event Handler for Post.
This section pertains to:
Recommended procedure for developing an Event Handler
Inheritance of Event Handler files
The Post Base File
When creating an Event Handler for Post, it is not necessary to start building from an empty file. NX has provided a number of Event Handler templates for you to use as a starting point when creating the Event Handler for your specific machine tool.
Start by selecting the Event Handler template with characteristics that most closely match the characteristics of the machine that you are creating the new Event Handler for. The Event Handler templates that are provided contain procedures to process all "standard" motion and event types.
Review the procedures contained in the template and make sure that there is a procedure for each event that your machine tool will recognize. You will need to develop a procedure for any event that is not already included in the template.
Review each procedure contained in the template to make sure that it processes the event correctly based on the specific requirements for your particular machine. Modify the existing procedure as necessary.
Using the procedures in the template as a guide, create procedures for each event that is not included in the template. Start with defining the variables that will be used by the procedure. Use the "global <variable_name>" command to do this. Next initialize those variables with the appropriate "default" value. Use the "set <variable_name> value" command to do this. Next, use "standard" and "NX" extended TCL commands to define how the event is to be processed.
You will probably need to add new Address and/or Block_Template definitions to the Definition File so that Post will know how to format the output of your procedure when it writes to the Output File. Refer to Developing the Definition File for more information.
When developing your Event Handler, you can include one or more event handler files. Post will use procedures contained in the included files unless they are redefined in the current Event Handler, in which case the the included procedures will be overridden. Use the "source <file name>" TCL command to do this.
In the case where multiple event handler files are "sourced", a procedure in the second "sourced" file will override a procedure with the same name in the first "sourced" file. Likewise, procedures in a third "sourced" file will override the procedures in the second and so on. Finally, a procedure in the current Event Handler will override all procedures with the same name contained in any of the "sourced" files.
Using this capability will allow you to quickly and easily develop the Event Handlers for similar postprocessors. By inheriting the procedures from existing event handler files, you only need to define modified, or additional, procedures for the differences.
A similar capability exists for inheriting existing definition files in the Definition File that you are developing. Refer to Inheritance of Definition Files for more information.
The following examples illustrate ways that you can use the inheritance capability.
Suppose that you have received a new machine controller with characteristics that are identical to an existing machine controller except that the new controller does not allow the spindle to be turned on while the tool is moving to its initial position after a tool change. The new controller requires that the spindle be turned on in a separated block.
Creating a new postprocessor for this new controller can be accomplished very easily by "inheriting" all the characteristics of the original Event Handler and Definition files and overriding the block templates and procedures related to turning on the spindle in the new Event Handler and Definiton files.
Suppose that your shop uses its own "standard" header information at the beginning of each postprocessor output file. Create a separate file containing "proc MOM_start_of_program" defining you shop's "standard header". Then "source" this file into each Event Handler that you use.
Similarly, a "standard" message to the machine operator at specific points in the postprocessed output can be accomplished in the same manner.
Once you have completed writing a new Event Handler, you may want to use the NX supplied debugging tool, or one that you have developed, to help with the debugging process.
You can "inherit" the procedures contained in the debugging tool file into the Event Handler that you are working on. When you have finished the debugging process, you can simply remove, or comment out, the one line "source" command instead of all the lines of code that make up the debug procedure. Refer to Debugging Your Postprocessor for more information.
The Post base file (ugpost_base.tcl) should be included at the top of every Post event handler TCL file. This is accomplished by including a statement similar to the following:
source directory_path/ugpost_base.tcl
The file consists of the data and the procedures that are common to any postprocessor, such as:
Default G/M codes
Errors and warnings output.
Opening the listing file: output file name(extension .lpt).
Opening the warning file: output file name(extension_warning.out).
Creation of the Listing file headers and the end information, such as the tool list with their usage, total time, number of warnings.
Setting the feedrate format as per the mode(per minute, per revolution, inverse time), and the value.
Handling the PPRINT output to the listing file.
Any utility functions and data, such as isset, PI.
The Post base file should not contain any data or procedures which are specific to any particular postprocessor. Such data and procedures should be implemented in the individual event handlers.
As a general rule, you are discouraged from modifying the ugpost_base.tcl file. If you desire to create your own library of utility data and functions, you should create a separate include TCL file.
Refer to Post Base File for an example of the Post Base file.