538 views
in Embedded Wizard Studio by

Why would a Property Observer not onEvent?

 

 

I'm definately entering into 'update' {}method for notify, a console.log('Here'); indicates such.

Outlet is specified right:

 

It was working at onepoint, and without me manually specifying a attachobserver. Is there someplace that a notify is auto specified when adding the brick, that may now be missing? Or is something wtihin my GasExchDialog, that the Observer is within, now amise?

 

1 Answer

0 votes
by

Hello,

I'm not sure whether I really understand the problem in your application. Is it not working? Or do you wonder how onEvent is signalled without being explicitly attached to the property?

In the second case, the attachobserver operation is performed by the PropertyObserver object. The object is actually configured with its property Outlet refering to the Application::Device.IRGA_ref_co2. Internally the object registers itself as observer for notifications triggered for this referred property. Then the object sends a signal to a slot method stored in its own property onEvent.

The method IRGA_update() is implemented to change the value stored in the property IRGA_ref_co2 and then to broadcast a notification to all observer attached to this property. Summarized, when you invoke the method IRGA_update() the native code in the slot method onEvent is executed. A further attachobserver is not needed.

Does it answer your question?

Best regards

Paul Banach

by
Yes, I understood as much. My problem is it's not executing the onEvent() despite being setup correctly. Why is the onEvent() not running when my {}method with the notifyobservers for it is executing? This one is baffling me to no end.
by

ok. The reason can be the missing _RequestUpdate() invocation.

The background: the GUI application is usually inactive. It wakes-up only when the user interacts with it or a timer expires. If you have code implemented in JavaScript, which is executed asynchronously and then you call from this code a method of the GUI application, the GUI application will not perform any pending operations unless timers expire or user interacts with the application. In such case _RequestUpdate() forces the GUI application to perform the updates. Please see also the sectoin Invoke GUI application code from device.

Assuming, you have some JavaScript code implemented containing the invocation of  IRGA_update(), then append the invocation of the method _RequestUpdate() at the end of your implementation. For example:

var device = EmWiApp._GetAutoObject( EmWiApp.Application.Device );

/* some asynchr. function */
function onMessage(evt)
{   
  /* Send data to GUI application */
  device.IRGA_update( some_value_if_any );


  /* Request the application to run an update */
  EmWiApp._RequestUpdate();
}

Does it solve the problem?

Best regards

Paul Banach

by

Some hint: in your thread How to properly handle native() with JS MessageEvents I saw the following code:

var device = EmWiApp._GetAutoObject( EmWiApp.Application.DeviceClass );

This will not work :o) The method _GetAutoObject expects the name of the object not the name of its class. In our example we use thus always the pseudo name DeviceObject to not mix with the class. In your case the object was named Device. You should thus adapt the implementation to following code:

var device = EmWiApp._GetAutoObject( EmWiApp.Application.Device );

Unfortunantly, if you have mixed the class with the object, _GetAutoObject() does not report any runtime errors ...

It would be great, if you could correct the example in the thread How to properly handle native() with JS MessageEvents :o)

Best regards

Paul Banach

by
var device = EmWiApp._GetAutoObject( EmWiApp.Application.DeviceClass );

Ah, very good! That was it! And I'll be sure to update the example thread.

Embedded Wizard Website | Privacy Policy | Imprint

...