105 views
in GUI Development by

Hi,

I have a question. I have created a DeviceClass named DeviceClassTermostato in the Unit Application.

In this class, I have some methods to control my device (e.g., changing the setpoint) and some properties that the device updates to the GUI (e.g., the temperature).


For this class, I haven't created the classic auto-object because I need to create it dynamically, depending on how many thermostats my device (ESP32) can control—one, two, or many.

Therefore, I have inserted an object (called ObjDeviceClassTermostato) of this class in the ThermostatClass GUI (called EncapsulatedTermostato). 

Above, I have a GUI class as a container that decides how many EncapsulatedTermostato objects to create on the screen. I do this with the code below in the init of the container.

Note that in DeviceClassTermostato, I have also created a property named ID to identify the ObjDeviceClassTermostato instance, and with the method "setObjDeviceClassTermoIDX( uint8 IDX)" in the EncapsulatedTermostato i can set the ID in the underneath Object instance.


I think this solution works well when I want to exchange data from the GUI to the device because in every method of DeviceClassTermostato, I pass the ID of the individual ObjDeviceClassTermostato instance initialized earlier.


The problem arises with data exchange in the reverse direction—from the device to the GUI. I don't know how to identify the object in DeviceDriver.c and .h.
In your example, you use EwGetAutoObject(&ApplicationDevice, ApplicationDeviceClass) because there is an auto-object, and that part is clear to me. However, with this solution I don’t know how to identify the object with ID = 1, 2, or 3 to send it the respective temperature property.

I hope I have explained the problem clearly.

1 Answer

0 votes
by
Hello,

as you already found out, there is no chance to access the right instance within your DeviceDriver.c file.

Maybe it helps if you create an autoobject of a DeviceClass that operates as Interface to your Termostato objects and all accesses are handled via this Interface using the ID. From your C code you can access this autoobject and provide the current data together with an ID.

Does this help?

Best regards,

Manfred.

Embedded Wizard Website | Privacy Policy | Imprint

...