Next: Understand what the Dezyne runtime is and how it should be used within your own application, Previous: Create a environment for the generated code to run in, Up: Code Integration Summary [Contents]
This learning goal covers the bulk of the section, 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 foreign 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 foreign 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 foreign 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.