31.01.2014 Views

Ph.D. - geht es zur Homepage der Informatik des Fachbereiches 3 ...

Ph.D. - geht es zur Homepage der Informatik des Fachbereiches 3 ...

Ph.D. - geht es zur Homepage der Informatik des Fachbereiches 3 ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

9.5. Implementation<br />

be discussed in certain detail.<br />

9.5.3. openETCS Generator Implementation<br />

Obviously, CCPPGenerator is the most complex generator class for creating the source code,<br />

which instantiat<strong>es</strong> the class<strong>es</strong> of the openETCS domain framework. Since nearly all objects in<br />

the openETCS C++ abstract syntax model are relevant for the domain framework instantiation,<br />

the complete C++ model must be traversed. Furthermore, the or<strong>der</strong> of the class instantiations<br />

is not arbitrary because some class<strong>es</strong> need other class<strong>es</strong> directly during their construction [79].<br />

For example, each CEVCState object needs its parent CEVCStateMachine instance to register<br />

itself as new state. Also, for other class<strong>es</strong>, it is nec<strong>es</strong>sary to primary create a vector of pointers<br />

to other already existing class instanc<strong>es</strong>, which are then used during the object construction.<br />

This is the case, for example, for CDataFlow objects, which need a vector of CFunctionBlock<br />

pointers, which defin<strong>es</strong> the objects used in the data flow. Therefore, several helper methods<br />

were implemented to separately handle the generation of different model parts and to provide<br />

a better structured implementation. For clarification, the whole generation proc<strong>es</strong>s is shown as<br />

UML interaction diagram from the view of the CMain class.<br />

In the first step, the GOPPRR C++ abstract syntax model is created by CreateSyntax-<br />

FromFile() method of the transformation class. This creat<strong>es</strong> the CGOPPRRSyntaxTree<br />

object m_pTree, which additionally creat<strong>es</strong> the un<strong>der</strong>lying m_pProject with the GOPPRR<br />

C++ abstract syntax model.<br />

Directly afterwards, the un<strong>der</strong>lying CProject instance is returned by the GetProject()<br />

method and checked for validity according to the static semantics because the generation<br />

proc<strong>es</strong>s should only be executed for valid models.<br />

CCPPGenerator Implementation The generation of the C++ source code for the openETCS<br />

domain framework instantiation is started by the Generate() method of the m_CppGenerator<br />

object. Initially, the GenerateRootGraph() method generat<strong>es</strong> all sourc<strong>es</strong> for the instantiation<br />

of the parent CEVCStateMachine object after the source file’s initial part 5 was added by the<br />

GenerateHea<strong>der</strong>() method. This is followed by the generation of all other objects by the<br />

related helper methods. All instantiations are generated surrounded by a main() function<br />

block [79] in or<strong>der</strong> that the source code file can be directly compiled as executable binary. Since<br />

only valid models are used for generation, the CCPPGenerator methods do not need a special<br />

error handling for faults related to the model. Only general faults, as segmentations, should be<br />

handled or, even better, avoided. Thus, most of the implementation of the CCPPGenerator<br />

methods is mostly the iteration over GOPPRR C++ abstract syntax model objects and do<strong>es</strong><br />

not need to be discussed here in more detail or by exampl<strong>es</strong>.<br />

More complicate is the generation of the execution or<strong>der</strong> of function block objects, which<br />

importance was <strong>der</strong>ived and explained in Section 7.6 and Section 7.7. Simplified expr<strong>es</strong>sed,<br />

function block objects should be executed in the or<strong>der</strong> of the direction of the data flow. In cas<strong>es</strong><br />

of open loops, this means starting from the objects that only have outputs. For closed loops,<br />

the start and end object cannot be defined in a general manner if they do not have any element<br />

5 with comments about creation time, model name, etc.<br />

171

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

Saved successfully!

Ooh no, something went wrong!