573 views
in GUI Development by

Hello,

I can't make the class TestsWindow show the number selected on the BarGraph used in TestsDialog.

Can you help me please? 

Thank you in advance,

Lucas

TestsDialog

TestsWindow

 

 

 

1 Answer

+1 vote
by

Hello Lucas,

it depends on your prefered approach. From your screenshots I see that both components (TestWindow and TestDialog) have a property TestsBatch declared as reference to an int32. I assume, this property is used to exchange the selected value. In such case:

- you will need to to connect the both properties to one and the same int32 property where the actually TestsBetch number is stored. Where such property is defined, depends on your desired application case. If this property is used to exchange data with the device, the property could be defined within a Device Class.

- after changing the selection in TestDialog you would modify the referenced property.

- Just in the moment you have modified the property execute the notifyobservers statement. You can do this explicitly after changing the referenced property or within the OnSet method of the referenced property.

If the above assumption was wrong (TestsBatch is used for other application cases and has nothing to do with the value displayed in TestDialog/TestWindow) you can use a variable within TestDialog to store there the corresponding TestWindow. In this manner, TestDialog can access TestWindow and trigger it to update its appearance just after the selection in TestDialog has been changed.

Best regards

Paul Banach

by

Hello Paul,

I think I got it. I've declared on DeviceClass the property TestsW in which OnSet method I declared its limits. I tried to use TestsW on TestsWindow/Dialog but it isn't working because I couldn't make property TestsW (DeviceClass - int32) the same type as in the TestsWindow/Dialog (^int32). It says that can't convert those types directly.

Is that right?

Lucas

TestsWindow2DeviceClass

by
That's how I wrote TypeW in DeviceClass:

if ( value < 1 )
  value = 1;
if ( value > 10 )
  value = 10;

/* check for new value */
if ( value == pure TestsW )
  return;

pure TestsW = value;

notifyobservers ^TestsW;
by

Hello Lucas,

your implementation of the OnSet method in the DeviceClass is correct. It defines an interface to store an int32 value. Every time a new value is assigned to this property (and after being validated for the range 1..10) all observer associated to this property are notified.

Now, you need to configure TestDialog and TestWindow so that both store in their TestsW properties a reference to your int32 property. To do this you will need an instance of the DeviceClass. Do you have already such instance? Usually if you create a new DeviceClass by using the templates, you will automatically get an associated autoobject. (a global instance of the corresponding class). If you are missing such object, create it first.

Then after you have opened again the class for the UI component TestWindow for editing, select in Inspector its property TestW and by using its assistant window assign to this property the property TestsW of the autoobject. After selecting the right item in the assistant you will get an initialization expression like ^VSG::Device.TestsW with the leading ^ sign which means that it is a reference to the property. Repeat the procedure for the class TestDialog. With this both UI components are connected now with the property TestsW of the particular object of the DeviceClass class.

Does it work now?

If not, please show me the implementation of the OnSetTestW method from the classes TestWindow and TestDialog. In order to receive notifications both need to register a slot method as observer for the just assigned property reference. See also attachobserver.

Best regards

Paul Banach

by

Paul, 

I changed the property "Type" in TestsWindow and TestsDialog from ^int32 to ^VSG::Device.TestsW and it's saying that it's an "Invalid datatype expression".

device

  • My OnSetTestsW from TestsWindow and TestsDialog are the same implementation:

/* check if something has changed */
if ( value == pure TestsW )
  return;

/* detatch from previous data point */
if ( pure TestsW != null )
  detachobserver onUpdate, pure TestsW;

/* store the new data point */
pure TestsW = value;

/* and attach to the new one */
if ( value != null )
  attachobserver onUpdate, value;

/* finally, get the initial value */
postsignal onUpdate;

by

Hello Lucas,

the implementation of the OnSet methods is correct. The modifcation of the Type attribute is not the right approach. All properties are already declared with the right types: the properties in TestWindow and TestDialog are declare as being able to store a reference to an int32 property. This int32 property is defined within the DeviceClass and accessible via an instance (the autoobject) of the DeviceClass.

- Please change the attribute Type of the both properties in TestWindow and TestDialog back to ^int32.

Maybe the cause why it is still not working is an error in my above explication. Thus please try following:

- Leave the both properties TestsW in TestWindow and TestDialog initialized with the defailt value null.

- Wherever you create and show TestWindow or TestDialog, modify the value of their property TestsW to refer to the property TestsW of the autoobject. You assign the expression ^VSG::Device.TestW to those properties.

Just in the moment you perform the above assignment, the TestWindow or TestDialog component will establish a connection to the DeviceClass and register a slot method as observer.

Maybe it will help you to read following articles describing the usage of references to properties as well as the concept of notifications:

Outlet properties

Notifications and Observer

Best regards

Paul Banach

by
Thank you for your patience Paul, it worked now!!

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

...