Create a translator

Create my first downloader

Previous  Chapter  Next

 

Introduction


The picture below shows the simplified sequence of the standard function calls.


Translator_Create_1

 

Each function has access to the dedicated object, for example an operation, but also to the controller, the electrical connected resources and the complete program.


Motion: A motion consists of one (linear or point-to-point) or two (circular) position objects (i.e. toolpath elements). Each position has its own coordinates, axis values, configuration, turn, etc. The motion can have events that effect before or after reaching the position. This means that the events are handled accordingly in the HandleMotion().

 

Operation: An operation normally contains several movements and combines them into a technological unit, for example a drilling point, welding seam or painting surface.

 

Operation group: An operation group encloses logical or technologically related operations in one group. The grouped operations can be manipulated together, as one entity.



Steps


1

Getting started

1.1

In Visual Studio Code open the HelloWorld.py from the example plugin, that has been implemented during the preparation. If everything is set up correctly, the picture should look like this.

 

Translator_Create_2

 

Trouble shooting:

PageParagraph_8 If the title bar is not green, please check if you selected the correct folder.

PageParagraph_8 If the imports are underlined yellow, please select the Python interpreter from the FASTSUITE Edition 2 installation.

Both issues are described in the Preparation page.

1.2

The name of the translator (file) and the Class names can be different. The file name is used and visible in the user interface. The class name is used internally.

Important is, that the name in DOWNLOAD_CLASS_NAME is equal with the used class name.

 

Translator_Create_3

1.3

The class from which it is derived, is specified within the brackets after the class name. In this case, it is the base class Downloader.

 

Translator_Create_4

 

Information_24

Important: It can only be derived from translators within the installation directory or the current plugin. Taking these conditions into account, several derivations are possible (like described in infrastructure overview picture in the Introduction page).


2

Create a program file and add content

2.1

There is a library command available which:

PageParagraph_8 creates a file if it does not exist.

PageParagraph_8 opens the file.

PageParagraph_8 adds content.

PageParagraph_8 closes the file.

 

To access that library, the import of FileUtility from cenpylib is necessary at the beginning of the downloader.

 

Translator_Create_5

2.2

To get access to the library in the entire class, we create class-wide access with self.FileUtil = FileUtility().

This means that the code only must be implemented in the first derivation. The access is then also available in the derived (child) classes (more later).

Do not forget to call the parent implementation of the __init__ function with super().__init__() especially in the child classes.

 

Translator_Create_6

2.3

In self.OutputFilePath we will store the output directory, including the file name and the file extension.

 

Translator_Create_7

2.4

The string array self.ProgramContent is used to add single lines to that array.

 

Translator_Create_8

2.5

At the end, the complete array is transferred to a file using the function AppendTextArrayToFile() from self.FileUtil.

 

Translator_Create_9


3

Get controller information and all connected joints

3.1

Here is an example of how to read the necessary information from the controller and access the axis mapping.

Add the following lines to the OutputHeader() function.

 

 

Translator_Create_10

3.2

Download the program in your scenario with this update and look for the results.

Example:

 

Translator_Create_17


4

Output all attributes defined on the operation

4.1

To be able to access an attribute in download, the attribute must be of type PROCESS_ATTRIBUTE. It is possible to change the property and visibility of attributes via technology customizing.

 

Translator_Create_11

4.2

Output all operation attributes with the property PROCESS_ATTRIBUTE.

Add the following lines to the OperationStart() function.

 

 

Translator_Create_12

4.3

Download the program in your scenario with this update and look for the results.

Example of the output that has been added:

 

Translator_Create_18

4.4

In this following example, only attributes that can be found on the operation or have been set on the operation are considered and have the property PROCESS_ATTRIBUTE.

To get a specific process attribute on the operation, the following function should be used.

 

Translator_Create_13


5

Output the motions

5.1

The entry to the motions and events is in the function HandleMotion(). First, the events before the movement are processed. Then the movements themselves are translated and finally then the events after the movement.

The example below contains an implementation for point to point, linear and circular motions. In this document we will only describe the linear output.

 

Translator_Create_14

5.2

Within the OutputLin() function, the string for the output is generated and added to the self.ProgramContent. The output of the self.ProgramContent has already been dealt with in the beginning.

Add the following lines to the OutputLin() function.

 

 

Translator_Create_15

5.3

Download the program in your scenario with this update and look for the results.

Example:

 

Translator_Create_16



Previous
Previous page
Chapter
Chapter page
Next
Next page