in GUI Development by

Hi Team,

we need to use array of structures to update GUI .

Could you please guide us on how can we achive this in Embedded wizard.

i have updated a small code snippet on what exactly we need.

typedef  struct
  uint16 MainID;
  uint16 u8ID1;
  uint16 u8ID2;
  uint16 u8ID3;


ParamM  ExampleMapping[]
    {MAIN_ID1,     150, 120 1},
    {MAIN_ID2,     150, 120 1},
 {MAIN_ID3,     150, 120 1},
 {MAIN_ID4,     150, 120 1},
 {MAIN_ID5,     150, 120 1},

we need an array similar "ExampleMapping".



1 Answer

0 votes

Hello Chaitra,

the concept like an array of data structures is not supported in Chora. What you can do is to represent the data structures as Chora objects. Then you declare the array with object as data type. At the runtime you create new instances of the Chora objects, store there the desired data and assign the object to an entry within the array. Depending on the number of array entries, this approach may become inefficient.

I suppose, your data sructures are originally stored in the device software and you want to map them to the GUI application, right? In such case the best would be to implement a dedicated interface between the GUI and the device. Through this interface the GUI application can query the number of entries in the array and query the structure data for an entry with a particular number. It is like an interface to a data base. In practice you implement such interface from Device Commands. For example:

- method int32 GetNoOfEntries() -> returns the number of entries existing in the array

- method uint16 GetMainID( int32 aEntryNo ) -> returns the value MainID from the array entry aEntryNo.

- method uint16 Getu8ID1( int32 aEntryNo ) -> returns the value u8ID1 from the array entry aEntryNo.

- method uint16 Getu8ID2( int32 aEntryNo ) -> returns the value u8ID2 from the array entry aEntryNo.

- method uint16 Getu8ID3( int32 aEntryNo ) -> returns the value u8ID3 from the array entry aEntryNo.

Does it help you further?

Best regards

Paul Banach

Hi Paul,

Could you please explain it further deeply?. In my case also I have to map data structures to GUI without using array as data storage. I need to store different types of data coming from end device at a time as data structures. In detail, The GUI should update a set of data which contains pH value, voltage value, temperature value and measurement status from the end device  to the corresponding field. For that, Do I need to have separate commands for each values or is it possible to have one command to define all the data structures? please clarify this in detail.


Hello Sazna,

if I understood your application case correctly, your device provides several values (pH, voltage, temperature, status) in a data structure.The question now, what should happen with the data in your application?

Option 1: The values are displayed (or processed) directly In the GUI application. For example, there is one Gauge to display the voltage and another Gauge to display the temperature. If this is your application case, see the section Implementing a Device Interface: Property. As explained in this section, you implement in your Device Interface as many properties as values you want to receive from the device. For example, one property for pH, one property for voltage, etc. Then you can connect the Gauge (or other widgets) to the properties. When new value is reported from the the device, the Gauge is automatically updated.

Option 2: The values are collected and several preceding values are displayed together. For example as a continuous curve. All data values are stored in the device within an array of size N. There are thus N x pH, N x voltage, etc. values stored in the device. In such case, the simplest approach would be to implement in the Device Interface a set methods to query the values stored at particular position. The following could be the corresponding methods. The parameter aEntryNo identifies which of the item within the array to query the value:

method int32 GetValuepH( int32 aEntryNo )
method int32 GetTemperature( int32 aEntryNo )
method int32 GetVoltage( int32 aEntryNo )
method int32 GetStatus( int32 aEntryNo )

The missing feature is the notification for the GUI that there is new data available (new item in the array). For this purpose I would use the System Event. When new data arrive, the device triggers the event. The GUI application receives the event and queries the new data using the above described Get methods. The GUI application could, for example, reload all values into a graph. If the number items in the array is dynamic, I would enhance the interface by a further method to query the actual number of values:

method int32 GetNoOfValues( void )

I hope it answers your question.

Best regards

Paul Banach

Yes, it does. Thank you for the explanation, 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