cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

Auto refresh widget - turn auto refresh on without first time refresh

aelgov
1-Visitor

Auto refresh widget - turn auto refresh on without first time refresh

Hi All,

I have a mashup where I show the current status of the device.

In this mashup I also let the user change the status of it.

Because I want to show the user the most current status of the device I refresh the screen every 10 seconds.

The problem - if the user choose to change one of the properties and didnt save yet, the refresh will reset its choise.

The solution, every time the user click on a button it will reset the auto refresh so it start counting from the begining and only if 10 seconds passed since the last time the user click on a button it will refresh the mashup.

Is there any way to do it?

When I toggle the refresh button (Change from ON to OFF) it will immidiately trigger the refrsh and not wait to finish counting.

ACCEPTED SOLUTION

Accepted Solutions
qngo
12-Amethyst
(To:aelgov)

To do what you want, I would need an auto refresh widget, a Validator widget, a session parameter of type DateTime and two services.

- Every time the user clicks on a button, if the auto refresh is stopped, start it. A service A is executed to set the current time to the session parameter.

- The auto refresh widget is updated every second and executes a service B. This service calculates and returns the different of time between the current time and the one set to the session parameter by the service A.

- The ouput (different of time, in second) of the service B is bound to an input of the Validator widget. This widget verifies if the different of time is more than 10 seconds. If true, the Validator executes the service to refresh the mashup and stop the auto refresh.

View solution in original post

7 REPLIES 7
jamesm1
12-Amethyst
(To:aelgov)

Is the status of the device a property? If so, as of TWX 7.1 (if I remember correctly) you can use websockets to update the property value instead of the refresh widget. Use the service GetProperties on the Thing or the Dynamic ThingTemplate/ThingShape and select the service in the mashup. On the bottom right, select the check mark for "automatically update properties when able"

autoupdate.png

Now, when the user changes the property, it should not refresh the property before the update is complete.

aelgov
1-Visitor
(To:jamesm1)

Thanks, it is not a property

jamesm1
12-Amethyst
(To:aelgov)

How are you storing the current status? Is this something like a service that returns a status from a remote system? How is this status being updated?

aelgov
1-Visitor
(To:jamesm1)

I'm calling a service that calls a remote service, he is doing some manipulation on the data and the status is coming from there.

BTW, I'm using TWX 6.6.9 and I cannot ATM upgrade to 7.X

jamesm1
12-Amethyst
(To:aelgov)

So is the issue that the refresh button causes a delay in seeing the updating status on the device, or does the refresh somehow cause the device status to be set back to its previous condition? I am imagining two services:

1. GetCurrentStatus()

2. SetCurrentStatus()

The refresh should be tied to the GetCurrentStatus service, and when some change is made on the mashup, we should call SetCurrentStatus(). Then, on InvocationComplete event of SetCurrentStatus, we should call GetCurrentStatus. Is this correct? How is the selection getting reset?

aelgov
1-Visitor
(To:jamesm1)

The issue is like this:

The way the auto refresh widget it working:

When you start the auto refresh it is immediately trigger the service and start counting for the next time to trigger it.

The way I wish the auto refresh widget will work:

When you start the auto refresh it will start counting for the next time (Not to start to trigger the service automatically).


Why I want it to work like this:

The device is a controller that can start a program, the controller can have the status: not active, running program X or Paused

Let's say the controller now is not active, in the mashup you can now choose if you want to manually run program X, by clicking the list and choose the desired program.

before you click start the program if the auto refresh will work it will reset the program number you chose because it is updating with the latest status of the controller and same place.


I hope I was clear this time.

qngo
12-Amethyst
(To:aelgov)

To do what you want, I would need an auto refresh widget, a Validator widget, a session parameter of type DateTime and two services.

- Every time the user clicks on a button, if the auto refresh is stopped, start it. A service A is executed to set the current time to the session parameter.

- The auto refresh widget is updated every second and executes a service B. This service calculates and returns the different of time between the current time and the one set to the session parameter by the service A.

- The ouput (different of time, in second) of the service B is bound to an input of the Validator widget. This widget verifies if the different of time is more than 10 seconds. If true, the Validator executes the service to refresh the mashup and stop the auto refresh.

Announcements


Top Tags