how to create array of structure

35 views
asked Jan 7 in GUI Development by Chaitra

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;

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".

Regards,

Chaitra

1 Answer

0 votes
answered Jan 8 by Paul Banach

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

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

...