Menu

Retrospect on Learning Goals

In the introduction of this tutorial, the following learning goals were mentioned:

  • Navigate through the essential areas of generated code

  • Create a native environment for the generated code to run in

  • Integrate every kind of event type in Dezyne with native code

  • Understand what the Dezyne runtime is and how it should be used within your own application

  • Compile an application consisting of native and generated code (in C++)

In this chapter, you will find a quick summary on each of the learning goals and where they were discussed in the tutorial.

Throughout the tutorial, code snippets from generated code were provided and key components in the generated code were highlighted. The intent is for you to be comfortable navigating through the code so that you can quickly find (and re-use!) what to implement in an inherited class or how to connect your event loop to the various System ports. In Inspecting the generated system you had a look at generated *.hh and *.cc files from a System component and in Implementation of events on interfaces and Implementing generated ‘skeleton’ components you encountered generated code for behaviour components and ports.

Create a native environment for the generated code to run in

Most importantly, this means properly initializing the runtime objects, supplying an event loop and making sure that files are named correctly. link:/Tutorials/Code_Integration_Tutorial/Using_Dezyne_in_your_C_Environment.html#CT101[Creating the native C environment], Including and configuring the dzn runtime and Next step in integration: detecting native components helped you in the initial steps of generating code, initializing the runtime and event loop and discovering which files need to be created. Chapter 3: Compiling your application provided some recipes to make the overall process easier.

Integrate every kind of event type in Dezyne with native code

This learning goal covers the bulk of the tutorial, with many different examples on the various integration techniques. In Implementation of events on interfaces, the following table was provided as a reference of when to apply what action:

Port type Event type User action

Provides interface (on top of a component)

In

Call Dezyne function from handwritten code

**

Out

Assign handwritten code to system function

Requires interface (on the bottom of a component)

In

Assign handwritten code to system function

**

Out

Call Dezyne function from handwritten code

Calling a Dezyne function from handwritten code can be seen in the event loop where sensorTriggered and passwordEntered events were fired as well as the Timer implementation where a timeout event was fired into the System.

Assigning native implementations to System functions was done with lambda expressions for the Timer start and cancel. Wrapping implementations in lambda expressions is an easy way to create std::function objects which Dezyne-generated C++ uses to store event handlers.

An alternative, more cohesive way of providing native implementations is inheritance of skeleton components. This technique requires a bit more work to set up, but when set up properly it is both safer and it becomes easier to track the behavior of your application. Examples for this technique are the LED, Siren and PWManager components.

The idea is generally the same as in the provided table, where assigning native code is replaced by implementing pure virtual functions. For out-events on required ports and in-events on provided ports, the calling of a Dezyne function is performed on the respective port.

Understand what the Dezyne runtime is and how it should be used within your own application

At this point you know enough about the runtime to successfully use it in your application; the instructions in Including and configuring the dzn runtime cover this. However, the locator and runtime can be used for various other things as well to make your life easier. This information will be discussed in the next chapter, Using the Dezyne locator to distribute (runtime) objects. What is explained there is not required to create a functional application, however there are some techniques that may prove useful for later projects.

Compile an application consisting of native and generated code (in C++)

Chapter 3: Compiling your application is, obviously, all about this specific learning goal. In this chapter, you can find an example makefile broken down into core features and quality of life improvements. If you followed the tutorial from the start up until this point, you will have noticed that the provided makefile handles expansion of the application very well. You should also be able to re-use the makefile for other Dezyne C++ projects easily.

Enjoy this article? Don't forget to share.