22.01.2015 Views

HDevelop User's Manual

HDevelop User's Manual

HDevelop User's Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 4<br />

Code Generation<br />

The idea of code generation is as follows: After developing a program according to the given<br />

requirements it has to be translated into its final environment. Here, you often don’t want to<br />

use <strong>HDevelop</strong> to save memory or disk space. In addition, the program should execute as fast as<br />

possible, especially without the overhead of an interpreter. Therefore, the program is transfered<br />

into another programming language that can be compiled and allows a faster execution. In<br />

addition to this, features of the new environment like special libraries or graphical user interface<br />

builder can thus be used.<br />

<strong>HDevelop</strong> allows to “export” a developed <strong>HDevelop</strong> program to the programming languages<br />

C++, Visual Basic, and C, by writing the corresponding code to a file. The sections 4.1, 4.2, and<br />

4.3 describe the general steps of program development using this feature for the three languages,<br />

including some language-specific details of the code generation and optimization aspects.<br />

Because <strong>HDevelop</strong> does more than just execute a HALCON program, the behavior of an exported<br />

program will differ in some points from its <strong>HDevelop</strong> counterpart. A prominent example<br />

is that in <strong>HDevelop</strong>, all results are automatically displayed, while in the exported programs<br />

you have to insert the corresponding display operators explicitely. Section 4.4 describes these<br />

differences in more detail.<br />

4.1 Code Generation for C++<br />

This section describes how to create a HALCON application in C++, starting from a program<br />

developed in <strong>HDevelop</strong>.<br />

4.1.1 Basic Steps<br />

4.1.1.1 Program Export<br />

The first step is to export the program using the menu Ð º ËÚ ×. Here, select the language<br />

(C++) and save it to file. In UNIX you specify the language by giving the file the extension<br />

“ºÔÔ”. A file will be created that contains the <strong>HDevelop</strong> program as C++ source code in a<br />

procedure ØÓÒ´µ. This procedure is called in function ÑÒ´µ. Besides the program code,<br />

the file contains all necessary ÒÐÙ instructions. All variables (iconic as well as control)<br />

81

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!