Skip to Content
AnpassungÜbersetzerErstellen Sie einen ÜbersetzerErstellen Sie meinen ersten Downloader

Erstellen Sie meinen ersten Downloader

Einführung

Das untenstehende Bild zeigt die vereinfachte Abfolge der Standardfunktionsaufrufe.

Jede Funktion hat Zugriff auf das zugeordnete Objekt, beispielsweise eine Operation, aber auch auf den Controller, die elektrisch verbundenen Ressourcen und das gesamte Programm.

Motion: Eine Bewegung besteht aus einem (linear oder Punkt-zu-Punkt) oder zwei (kreisförmig) Positionsobjekten (d.h. Werkzeugweg-Elementen). Jede Position hat ihre eigenen Koordinaten, Achsenwerte, Konfiguration, Drehung usw. Die Bewegung kann Ereignisse enthalten, die vor oder nach dem Erreichen der Position wirken. Das bedeutet, dass die Ereignisse entsprechend in der HandleMotion() verarbeitet werden.

Operation: Eine Operation enthält normalerweise mehrere Bewegungen und fasst diese zu einer technologischen Einheit zusammen, beispielsweise einen Bohrpunkt, eine Schweißnaht oder eine Lackierfläche.

Operation group: Eine Operationsgruppe fasst logisch oder technologisch zusammenhängende Operationen in einer Gruppe zusammen. Die gruppierten Operationen können gemeinsam als eine Einheit bearbeitet werden.

Schritte

1. Erste Schritte

In Visual Studio Code open 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.

Trouble shooting:

  • If the title bar is not green, please check if you selected the correct folder.
  • 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.

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.

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.

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. Erstellen Sie eine Programmdatei und fügen Sie Inhalte hinzu

There is a library command available which creates a file if it does not exist, opens the file, adds content, and closes the file. To access that library, the import of FileUtility from cenpylib is necessary at the beginning of the downloader.

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.

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

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

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

3. Controller-Informationen und alle angeschlossenen Gelenke abrufen

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.

# get log operator logger = operator.GetLogOperator() logger.LogInfo("Default OutputHeader called") self.ProgramContent.append("Controller: %s, Manufacturer: %s" % (controller.GetName(), controller.GetManufacturer())) self.ProgramContent.append("Model: %s, Series: %s" % (controller.GetModel(), controller.GetSeries())) # get all electrically connected joints connectedJoints = controller.GetConnectedJoints() # iterate through the list of joints for joint in connectedJoints: self.ProgramContent.append("Joint: %s, DOF number: %d" % (joint.GetName(), joint.GetDofNumber())) self.ProgramContent.append("Group index: %d, joint index: %d" % (joint.GetJointGroupIndex(), joint.GetJointIndex()))

Laden Sie das Programm in Ihrem Szenario mit diesem Update herunter und überprüfen Sie die Ergebnisse. Beispiel:

4. Geben Sie alle auf der Operation definierten Attribute aus

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.

Output all operation attributes with the property PROCESS_ATTRIBUTE. Add the following lines to the OperationStart() function.

for att in operation.GetAttributes(): self.ProgramContent.append('Operation attributes: ' + str(att.GetName()) + ',' + str(att.GetValue()))

Laden Sie das Programm in Ihrem Szenario mit diesem Update herunter und prüfen Sie die Ergebnisse. Beispiel für die hinzugefügte Ausgabe:

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.

5. Ausgabe der Bewegungen

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.

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.

# get cartesian coordinates xyz = position.GetXYZ() angles = position.GetOrientation() # convert them to meter convertToMM = 1000 X = xyz[0] * convertToMM Y = xyz[1] * convertToMM Z = xyz[2] * convertToMM # add motion instruction to the program content self.ProgramContent.append(" X:%.3f mm Y:%.3f mm Z:%.3f mm" % (X, Y, Z)) self.ProgramContent.append(" Rx:%.3f deg Ry:%.3f deg Rz:%.3f deg" % (angles[0], angles[1], angles[2])) self.ProgramContent.append("")

Laden Sie das Programm in Ihrem Szenario mit diesem Update herunter und überprüfen Sie die Ergebnisse. Beispiel:

Was this page helpful?