164 views
in Embedded Wizard Studio by

Hi,

According to the document, if we implement a variant for a deviceclass and the variant condition is true, the original implementation should no longer be available:

https://doc.embedded-wizard.de/managing-project-variants?v=12.00#3

 

However, I found that the generated code still contains the code for the original class. For example, belowing the "Coffee Machine" project from the "Quick Tour" example.

The DeviceClass contains the native code that would call the C function "YourDevice_StartBrewing()". But even if I select the VariantCond on  "DeviceClassVariantForPrototypeOnly"  to be true, the generated code still contains the code for the original class, although the variant is actived successfully when I run the code on the target hardware.

Is there something wrong here?






Thanks!
John


 

1 Answer

+1 vote
by
 
Best answer
Hello John,

The class variants follow similar rules as regular class derivation. Therefore the original class is still necessary. The variant depends on it, overrides and enhances its functionality - even if the variant condition is true.

In case of the Quick Tour example, the variant is intended to be used during prototyping only (to simulate the real coffee machine behavior). The variant is not intended for code generation in this example.

I hope it helps you further.

Best regards

Paul Banach
by

Hi Paul,

Thanks for replying. I know that the variant on that project is intended to be used during prototyping, I was just trying to run the same code on the hardware.

Anyway, I also saw that the variant is working differently on the Bitmap Resouce. I mean if I create a variant for the Bitmap Resource and set the variantcond to be true, I found that the generated code would only contain the bitmap data for the variant. This is good. This is what I expected on the deviceclass variant, the generated code shouldn't contain some piece of code that would never be called.

But this is not  really a problem now, I know how to avoid it. Thanks!

Best Regards,

John

by
Hello John,

you are right, bitmap variants (fonts or constants too) are different. This is because they don't use inheritance. A static bitmap variant simply replaces the original bitmap resource. Classes, in turn, may contain functionality which is inherited and can be modified/enhanced by the variants.

I hope it helps you to understand the technical backgrounds of this functionality.

Bst regards

Paul

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...