Closed wildmeng closed 1 year ago
Firstly for any event to be sent, the USP Controller must have setup a subscription for that event in Device.LocalAgent.Subscription. This is the most common cause of not getting an event.
USP_REGISTER_Object_RefreshInstances() can be used to register a callback that is called when the instance cache needs to be refreshed for the object. It can only be used for a top level object (ie one immediately below Device.). The callback must call USP_DM_RefreshInstance() once for each instance in the top level object and any child objects. If a subscription has been set up for object added/deleted, then the callback will be called periodically, and if the set of instances registered by calling USP_DM_RefreshInstance() have changed, then OBUSPA will detect this, and send an event.
ah, understood! so, if USP_DM_RefreshInstance is called in callback for USP_REGISTER_Object_RefreshInstances, then the events would be sent later by the obuspa.
but this brings up another issue: the event can not be sent in time, for example, I noticed that the ValueChange event is processed in a periodic timer every 30 seconds by default, our customer complained that it's too long.
wouldn't be better to provide the APIs to send the ValueChanged event by the upper application module itself?
Call USP_SIGNAL_ObjectAdded() and USP_SIGNAL_ObjectDeleted() if you want the event to be sent immediately. But if you can only generate these events by polling the instances then it doesn't make sense to poll too frequently as it uses too much CPU. If you still want to poll more frequently, then VALUE_CHANGE_POLL_PERIOD in vendor_defs.h can be made smaller.
thanks for your answer: still two questions: 1, if the USP_SIGNAL_ObjectAdded is also called, would a duplicated event sent later by the poll process? 2, Is there API to send the ValueChange event immediately?
no way to send ValueChange event immediately ? maybe the poll machasim is mainly for read-only parameters, however, for writable parameters, it's possible to send event immediately when it's set?
Unfortunately OBUSPA does not yet support a subscribe/notify mechanism for value change notifications. This would be mainly useful for parameters stored in a database or, as you say, parameters that have been written by a controller via OBUSPA.
Closing this issue, as queries have been answered and there has been no further activity on this ticket for a month. Please re-open if there are any continuation queries.
Hi, I am tying to implement the event for the ObjectCreation and ObjectDeletion, it seems a periodic schedued task is need to check for read-only mulit-instance object and compare to the pre-existing instances. and I found following desciption in the Quick-Start Guide:
According to the description, it looks lik the USP_SIGNAL_ObjectAdded and USP_SIGNAL_ObjectDeleted can be avoided through the USP_REGISTER_Object_RefreshInstances , but it seems to me the USP_REGISTER_Object_RefreshInstances doesn't send any event.
Much appriciated if you can help clarify!
Thanks!