Skip to main content
1-Visitor
November 21, 2016
Solved

How to check result of property from GetImplementingThingsWithData

  • November 21, 2016
  • 6 replies
  • 3708 views

Hi everyone,

I have multiple things which are based on a ThingTemplate. I use GetImplementingThingsWithData to get all the values of one property (state) of all implementing things. Now I want to check if the values of the property have changed. If they have changed I want to trigger an event which can be used to invoke a service that updates a widget.

I tried to achieve this with:

a) Validator and its true-event

This is not working because I cannot handle the list of booleans in the expression.

b) Write a custom service which checks the input and emits an event.

I don't know how to use the custom event to update a widget by invoking another service in the mashupbuilder.

It would be really nice if someone can give me a hint.

Cheers

Sebastian

Best answer by skoessler

In the end my solution looked something like this:

I implemented a custom service which used GetImplementingThingsWithData to retrieve all states of my observed things. The Booleans are persisted in an infotable. The infotable is used to compare the current states with the old states. The service returns a boolen to signal if a state has changed.

In the mashup I triggered the custom service with the autorefresh widget.  Also an validator and its true event was used to invoke the service which is used to update the information on the map.

I'm not happy with this approach but it works for now.

6 replies

5-Regular Member
November 22, 2016

I believe all you need is the auto-refresh widget. Just set this to refresh every 5-10 seconds and bind the refresh event to the service which populates the data on your mashup. You may need to set the Data Change Type to Always on the properties as well. The auto-refresh widgets do not need to be visible on the mashup to work.

Hope this helps!

skoessler1-VisitorAuthor
1-Visitor
November 22, 2016

Hi Tori,

I forgot to mention that I want avoid the auto refresh widget because than the map keeps blinking and produces a lot of cpu load. Also fast reaction times are needed that's why 5-10 seconds are not acceptable.

Thanks

Sebastian

5-Regular Member
November 22, 2016

I don't see how you'll avoid the "flashing". If you need to update the data bound to a map widget, you have to call the service to retrieve the data, which will update the map widget

skoessler1-VisitorAuthorAnswer
1-Visitor
November 28, 2016

In the end my solution looked something like this:

I implemented a custom service which used GetImplementingThingsWithData to retrieve all states of my observed things. The Booleans are persisted in an infotable. The infotable is used to compare the current states with the old states. The service returns a boolen to signal if a state has changed.

In the mashup I triggered the custom service with the autorefresh widget.  Also an validator and its true event was used to invoke the service which is used to update the information on the map.

I'm not happy with this approach but it works for now.

5-Regular Member
November 29, 2016

There is an enhancement request open for this Jira. Documentation is in KCS Article CS251652. In the meantime, this workaround seems good to me.