How to get values from a GUI to build a logic?

147 views
asked Feb 11, 2019 in System Integration by elage.lucas
Hello,

After GUI is done I want to integrate it with a device, it will control some relays.

To do it I need to know which options the user have selected in my interface, there are 4 classes with different options for configuration of control.

How can I get it to build a script in C, using switchcase functions?  

Thank you

1 Answer

0 votes
answered Feb 12, 2019 by Manfred Schweyer

Hello Lucas,

based on the provided information, it is not so easy to give you some helpful advice.

I think you are using the STM32F746 Discovery board. Have you seen the example DeviceIntegration from the folder /Examples within the Build Environment? It demonstrates how to access a LED from the GUI application. You can access your relays in same manner.

Furthermore, let me refer to the articles Integrating with the device and Device Class and Device Driver, both are part of our online documentation. They explain all basics about natvie code and the integration of external software APIs or hardware drivers.

Hope this helps...

Best regards,

Manfred.

commented Feb 13, 2019 by elage.lucas
Hello Manfred,

I read the documentation but didn't quite get it.

The user will select a couple of options (on TypeWindow and DepthWindow classes) and I need to recognize it, so depending on his choices it has to go to a case in a switchcase logic. (e.g. TypeButton1&&DepthButton3 => case 5)

Do I have to use an observer on those classes? How can I do it?

Thank you in advance,

Lucas
commented Feb 13, 2019 by Manfred Schweyer
Hello Lucas,

I know, the referred articles explains all the theory and mechanisms to combine a GUI application with an underlying system.

As far as I understood your use-case, you have several options that are selected by the user (e.g. via checkboxes) which are stored as separate properties within your Device Class. In order to evaluate the current settings, you can create a method (e.g. "UpdateDevice") within your DeviceClass and within all onset-methods of the different properties within the Device Class you call UpdateDevice(). Within UpdateDevice() you implement your logic to evaluate the current states and call the underlying Device Driver according the current situation.

This means: It is not necessary to make a call to your Device Driver directly within every onset method of your properties - you can just call your own method that evaluates several properties and transfers the result to the Device Driver.

Does this answer your question?

Best regards,

Manfred.
commented Feb 13, 2019 by elage.lucas
Hello Manfred,

It makes clearer for sure, thank you for your answer.

I'm trying to call UpdateDevice within the onset methods using 'notifyobserver' but it's not recognizing it.
I wrote an if/else logic in UpdateDevice and it calls my DeviceDriver where I wrote a logic to be done on the STM, but I'm not being able to communicate my checkboxes with the DeviceUpdate.

Do you have any examples of this kind of application, using ifelse/switchcase statements, that I can take a look?

 Thank you in advance,

Lucas

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

...