7 Replies Latest reply on Feb 20, 2017 4:25 AM by qngo RSS
    aelgov Apprentice

    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.

      • Re: Auto refresh widget - turn auto refresh on without first time refresh
        jamesm Creator

        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.

        • Re: Auto refresh widget - turn auto refresh on without first time refresh
          qngo Creator

          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.