Skip to main content
15-Moonstone
December 14, 2020
Solved

how to refresh mashup when service return data changed?

  • December 14, 2020
  • 2 replies
  • 3428 views

Dear community,

 

I wrote a Mashup and a service. The logic of the service is: the input parameter is a data from the PLC. After a series of processing, the service generates a data as an output parameter, and then binds the output data to the mashup.

 

Now I want to realize that when the PLC data changes, the data displayed by Mashup automatically changes, what should I do?

 

I tried to use the AllDataChanged function, but it failed.

 

 

 

 

 

 

Best answer by zyuan1
The backend of TWX, ie. Subscription, can respond to PLC change as soon as possible, and you can use it to send out email alert and other reactions. Mashup is just a place to present the situation to viewer. By using a 1 s auto-refresh widget to update the warning status, the user will only get the message at most 1 second late, and if you've configured automatic response to the incident, it will be taken care of before User noticed, the delay in mashup won't be much of a problem.

2 replies

5-Regular Member
December 14, 2020

One of the way - On the mashup it self you can use autorefresh widget's refresh event to call that particular service in a time interval. The time interval can be decided on the basis of data change frequency of the PLC data. You can set the time in widget property itself.

15-Moonstone
December 14, 2020

Thank you very much for your quick reply, because the value of PLC will change from time to time, so I canโ€™t use autorefresh. Is there any change in plc value to trigger the update of mashup? Looking forward to your reply. Thank you!

5-Regular Member
December 14, 2020

Hi @CZ_9645217 ,You can use  GetProperties service if you just want the data from the device. In the Data Properties panel, when the Automatically update values when able check box is selected and the mashup is viewed, the mashup run time creates a websocket connection with the ThingWorx Platform and subscribes to the properties that are bound to widgets.

 

If its a custom service you can go with auto refresh widget.

15-Moonstone
December 14, 2020

Thank you very much for your quick reply, because this is a customized Service, is there any solution to trigger the update of the mashup by changing the service output value? Looking forward to your reply

5-Regular Member
December 16, 2020

The tricky part is turning an input/property change to an event in the mashup, so that other services can be triggered, such as the refresh service in Mashup.

 

Value change can trigger a subscription, but it cannot affect mashup, "Alldatachange" and autorefresh maybe the only solution.

 

You can use the PLC data change to record data history to ValueStream, while apply the autorefresh in mashup; Thus the data won't get missed from your log, and the mashup would be more user friendly. (some mashup services may request a longer time to finish execution than your PLC data update frequency, and then the mashup won't be able to present all the data.  And if the remote data doesn't update that fast, an 1 s refresh interval won't be good enough for that)