|
The Sodick Post Processor
This section explains how the Sodick EDM Setup PP is written, complementing the documentation inside the EX2 file.
The Sodick format is actually an XML-based format known as EPX 2 (developed by the Japanese JaDMA association). It is used by several Japanese EDM machine vendors, and is not trivial to generate.
The difficulty lies mainly in the file structure, which is different than the structure of the GPP2 EDM program (namely, the order of blocks). Therefore, extensive use of bookmarks was necessary for the Sodick PP. Another complicating topic is the use of images, which must be manipulated and stored in specific folders.
The Sodick PP supports both the "new" EDM setup mode, as well as the "legacy" mode. With a "new" profile, specific operations can be selected and output. Recall that an "operation" is defined as applying a given tool (For example, Electrode 1 Rough) at a given location (For example, Location 3 of Electrode 1). Under a "legacy" profile, selection is limited to locations, so all tools are output for each chosen location. In both modes, locations are written from the BEGINNING OF OPERATION block.
XML Files
XML files are made of "clauses" and sections.
A typical clause contains a single data item, with the data item name and value, as follows:
<Name>Value</Name> For example, <work_piece_name>Part0-EL</work_piece_name>
The value is enclosed within start and end phrases that contain the parameter name.
For null values, XML has a shortcut, containing the name only, as follows:
<Name/> For example, <comment/>
Entire sections may be contained within the start and end phrase. For instance, the Sodick file has a header section starting with <header> and terminated with </header>. Many clauses and other sections may be enclosed between the start and end phrase. Any level of section hierarchy is allowed.
Below is a typical XML section describing the start position of a location:
<start_position>
<X>-28.7730</X>
<Y>30.8282</Y>
<Z>145.9000</Z>
<C>0.0000</C>
</start_position>
Newline characters are typically not used in XML file, which makes them hard to view or edit in text editors like Notepad. The XML file looks like one long line. However, newline characters are harmless, and the XML files generated with GPP2 do contain them. Every clause is output on a separate line.
EPX 2 File Structure
Like every XML file, the file is hierarchic in nature, as follows:
Header General information, like date and author name.
Work-piece information: Job-level information, mostly image names.
Electrode Multiple sections, one per electrode
Electrode Tools Up to 4 sections, for Rough, Pre-Finish, etc.
Electrode Images Every tool contains up to 9 image names
Locations List of locations used for that electrode tool
Notes:
The number of tools used per electrode (Rough, Pre-Finish, etc.) must be counted and specified at the beginning of the “Electrode Tools” section.
The number of locations per electrode tool needs to be specified at the beginning of the “Locations” section. However, that number is truly only known after all operation blocks have been processed, and usage of each tool have been counted. This is a major reason for the extensive use of bookmarks in this PP.
The number of bookmarks in GPP2 is limited to 1,000. Since up to 8 bookmarks are needed per electrode (2 per electrode tool), the PP is limited to 120 electrodes. Trying to output more than 120 electrodes will result in a run-time error (see BEGINNING OF EDM block).
The Sodick EPX 2 Style Sheet
AN XML file may include reference to a "style sheet", which describes how the XML file should be displayed (rather than the default tree-style way). The Sodick XML file uses a style sheet named "defstyle.xsl" that is provided with the Cimatron installation. The definition is the second clause in the XML file:
<?xml-stylesheet href='defstyle.xsl' type='text/xsl'?>
In order to work properly, the style sheet file must be present at the same folder as the output file. It is copied there by GPP2 (in the POST SCRIPT block) from the Cimatron "data" folder (ROOTE_PATH\..\data).
Note: If you wish to view the XML file without the style sheet, that row must be deleted (use Notepad).
Use of Bookmarks
Two bookmarks are created for each electrode tool (Rough, Finish, etc.). The bookmarks are set dynamically, as the PP encounters electrodes. The system variable ELEC_SEQ counts the electrodes used in this run (starting with 1), and so bookmarks are created at ELEC_SEC * 8 (each electrode gets a space of 8 bookmarks, 2 per tool – up to 4 tools).
Two bookmarks are needed per tool since we need to write two separate things as we process the operations for that specific tool: the number of locations and the location data itself. Therefore, two distinct bookmarks are necessary. See use of SET_BOOKMARK inside ElectrodeTool.
An electrode with 4 tools (Rough, Pre-Finish, Finish and Polish) will utilize all 8 bookmarks, while an electrode with fewer tools will use fewer bookmarks. See the calls to procedure ElectrodeTool, where the PP creates a section per tool and also sets the two bookmarks needed for that too. There are separate calls for Rough, Pre-Finish, etc.
In procedure WriteLocationInfo, the PP opens the relevant bookmark for this location of the specific electrode tool, and writes the necessary location data. It also counts the use of that tool in an array called OperationCnt. That array has an entry for each electrode tool (up to 480 tools).
Finally, at the end of the run (at END OF EDM), the number of locations used per tool is known (in the OperationCnt array), and the PP writes these numbers to the other bookmark of each tool. See procedure WriteLocationCnt.
Handling Images
The Sodick profile allows the user to define many image files that are part of the output.
Up to 12 images can be defined at the "job" (component) level. They are grouped in four image groups, of up to 3 images each, and are listed in the <work_piece_information> section. These images have to be copied to a sub-folder called workpiece (done in the POST SCRIPT block).
Up to 9 images can be defined per electrode, grouped into 3 image groups, of up to 3 images each. These images are listed on every tool of that electrode. So, if a given electrode has 7 images and uses all four tools (Rough, etc.), these 7 images are listed 4 times (exactly the same information). These images have to be copied (once only!) to a sub-folder called electrodes (done in the POST SCRIPT block).
For all images, only the file name (without the full path) has to be listed in the XML output file. The full path has to be kept for the POST SCRIPT block, where the files must be copied to the target sub-folders.
It turns out that only BMP images may be used as part of the Sodick EPX 2 output. Therefore, other file formats, such as JPEG or TIF must be converted to BMP. For that purpose, the Cimatron installation includes a conversion program called ConvertToBMP, and residing in the Cimatron root folder (ROOTE_PATH). Images are converted from whatever format they have (typically JPEG) to BMP (all that is done in the POST SCRIPT block).
Regrettably, the ConvertToBMP program does not recognize the JPEG file extension, but works fine with the JPG file extension. The PP identifies any image with JPEG extension and renames it to JPG before the conversion.
In order to handle all that, a lot of string manipulation takes place in the PP, separating the file name from the full name, and keeping all names in arrays, for the POST SCRIPT block:
Procedure SplitImageName takes an input full path parameter and breaks it into two strings, ImagePath holding the folder, and ImageFile with the file name. It also copies the file name but with a BMP extension to variable ImageBMP.
RecordWPImage gets one of the work-piece images and (if not null) counts it and saves (a) the full path; (b) the BMP image name; and (c) the original image name, in two arrays. It is called at BEGINNING OF EDM on all 12 work-piece images.
RecordElecImage does the same for electrode images. It is called at BEGINNING OF ELECTRODE on all 9 electrode images.
ImageGroup outputs an entire image "group" of up to 3 images. It is used to output both work-piece images (part of the < work_piece_information> section) and for electrode tool image groups (part of every electrode tool). It counts the number of images (empty names mean no image) and creates the proper image group. It uses procedure ImageInfo to write individual image sections.
Post-Script Block
The POST SCRIPT block is mainly used to copy and convert image files, as explained above.
It starts by creating the two sub-folders ("workpiece" and "electrodes"). Then, it goes over the arrays where all the image data was collected during the run.
For each image (work-piece or electrode) it does the following:
Copy the original image to the proper target sub-folder.
If extension is JPEG, rename file to have extension JPG.
If file extension is not BMP:
Convert file to BMP
Delete original file
The POST SCRIPT block also copies the XML style sheet file (defstyle.xsl) to the output folder.
A special "POST SCRIPT: stopped:" block handles runtime errors. It deletes the output file, to avoid creating partial and erroneous output.
|