1.7k views
in Getting started by
I want the GUI to be able to display that it recieved the correct message in response to a UART output from the board. I'm uncertain how to make the SystemEventHandler take the message so I can process it.

1 Answer

+3 votes
by
 
Best answer

Hi,

try following:

Step 1: In Embedded Wizard switch to your driver class.

Step 2: In the Gallery Templates window switch to the folder Device.

Step 3: In the folder look for the template System Event.

Step 4: Drag-and-drop the template to your device class.

With the template you add to the device class an object representing the system event and a method intended to trigger the event from the outside of the GUI application. This means, the code receiving the UART data should call the trigger method. Following is the situation in Embedded Wizard after adding the System Event template. here the system event object object is called SystemEvent1 and the corresponding trigger method TriggerEvent1:

Step 5: In your 'C' code where the UART data is received implement all the necessary evaluation, etc. operations to decide whether the UART data is o.k. or not. Depending on the results you can invoke now the above mentioned trigger method.

To do this you need to access the autoobject representing the device class. Assuming, you have created the device class by using the template Device Interface, such autoobject is automatically provided. For example:

The article Invoke GUI application code from device describes how you access such autoobject and invoke its method. In this simple example with the autoobject named Application::Device and the method named TriggerEvent1() the following ANSI C would send the event from the 'C' world to the Embedded Wizard GUI world:

if ( uart_data_is_ok )
{
  /* Obtain access to the autoobject */
  ApplicationDeviceClass device = EwGetAutoObject( &ApplicationDevice,
                                                    ApplicationDeviceClass );

  /* Invoke its method */
  ApplicationDeviceClass__TriggerEvent1( device );
}

Step 6: Now, wherever you want to handle the new system event within your GUI application you simply add the System Event Handler. Similarly to the steps described above, drag-and-drop the template System Event Handler from the folder Device to the GUI component where you want to react to the event.

With this template you get a system event handler object and an associated onEvent slot method. For example:

Step 7: Select the SystemEventHandler object and in Inspector window locate its property Event. With the Inspector Assistant window you can now connect the handler object with the system event object defined in the step 4 within the device class:

Through this connection, every time the system event is triggered (step 5), the handler object will received notification. Automatically. You don't need to take care of it.

Step 8: Finally, open the slot method onEvent associated with the system event handler and implement there the code to perform when the event arrives.

If desired, you can maintain several system event handlers within diverse GUI components, all connected with the same system event object. When the system event object is triggered, all handler are notified.

Hope it helps you.

Best regards

Paul

by
Thank you very much!

A quick second question:

Would the context class be the the appropriate way to send the message received to the GUI? If so, how would I access the data recieved in the C files from Embedded Wizard?

For example: I take in a value sent to the board via UART, and I want to print it to the screen.
by

Please have a look to the article "How to send string from usart and show it in the gui" - I hope this answers your question.

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

...