110 views
in GUI Development by
Hi,

Inside Application unit, I created a enum set and named it as enum_set_1 and inside of that I've added  enum items say FirstItem, SecondItem, ThirdItem like that. similarly I've created another enum set as enum_set_2, enum_set_3 and enum_set_4 respectively with some enum items say item1, item2, item3 like that.

I created a class data_channel with var1 of type Application::enum_set_1  and var2 of type Application::enum_set_2 as a property. And I've added one variable say data of type uint32. I've added one method, so as to give var1, var2 and data as an argument. The method will return one uint32 value to be stored in the variable address data. So If I use this data_channel object inside other Application classes I can able to configure the var1 and var2 just by clicking the drop down button in the attribute of var1 and var2.

Similarly, if I choose var1 value as FirstItem, I want the var2 type should be changed as some different enum set, say enum_set_3, and for SecondItem var2 type should be changed to another enum set, say enum_set_4.

So how we can achieve this before generating code itself.

1 Answer

0 votes
by

Hello,

Similarly, if I choose var1 value as FirstItem, I want the var2 type should be changed as some different enum set, say enum_set_3, and for SecondItem var2 type should be changed to another enum set, say enum_set_4.

If I understood your application case correctly, it would expect a method with its second argument to be dynamically typed depending on the value of the first argument. Since Chora is a statically typed language, all operands as well as arguments have to be well known concerning their data types. Changing the types dynamically at the runtime is not possible.

As workaround, you could implement the method with int32 (or uint32) typed arguments instead of enums. Doing this you can still pass enums via method arguments. Chora provides for this purpose typecast operators to convert between enum <--> int32 or uint32. See also Type conversion: Enum data types and integer. Using the typecasts you could convert the enum_1 to int32 or enum_2 to int32 and pass the value to the method.

I hope it helps you further.

Best regards

Paul Banach

by
Actually, the use case of the method will be, I'm passing two arguments var1 and var2 that's correct. For var1 if I select FirstItem then var2 should be loaded with corresponding enum set to be mapped with var1. I don't want this one to be changed in runtime. Why because, just in the time of configuration itself I want to implement this one.

For example, If I selecting var1 as vegetable type, then var2 shoul be loaded with vegetable names, say potato_enum, tomato_enum, brinjal_enum etc. Similarly if I selecting var1 as fruit type, then var2 should be loaded with fruit enum names, say apple_enum, banana_enum, orange_enum etc like that
by

Hello,

For var1 if I select FirstItem then var2 should be loaded with corresponding enum set to be mapped with var1. I don't want this one to be changed in runtime. Why because, just in the time of configuration itself I want to implement this one. 

this would result in the type of var2 depending on a selection of var1. This approach is not possible.

Best regards

Paul Banach

by
Thanks Paul for your inputs

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

...