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

Simulate Live Data in Vuforia Studio using Java Script

Visitor

Simulate Live Data in Vuforia Studio using Java Script

I am looking to change the data in a 3D gauge using Java Script to simulate live data. Any suggestions?

2 REPLIES 2

Re: Simulate Live Data in Vuforia Studio using Java Script

Hi @dallen3 ,

 

here a very simple example simulating a value:

So following demo project :

 

2019-09-13_17-29-50.gif

 

In this project I have a 3D gauge "3DGauge-1" and application parameter RPM

Then added the following script:

 

 

////////simulate properties
 //this will set the applicaiton parameter "RPM" to random value between 1-100
 function setRPMValue()
{
   
   var  retValue  = Math.floor(Math.random() * 100)+1
   $scope.app.params['RPM']= retValue;
//print in the debugging consol  
console.log("rpm callback to value="+retValue)
    }
//will call this function every 1 sec
var timerId= setInterval(setRPMValue,1000,true)
//////// watch construct which watch the change of the app parameter "RPM"
$scope.$watch(
  function() 
  { return $scope.app.params['RPM']; }
  ,
  function() 
  { //set the value of the gauge
$scope.view.wdg['3DGauge-1']['text']= $scope.app.params['RPM']
 });

 

The code will change the value of the application parameter RPM to random value in range 1-100 

The interval callback will call the  setRPMValue function every 1 sec

The $watch construct will bind the value to the gauge text property. Of course, you can use direct binding from application parameter "RPM" to 3DGauge-1 .text. In this case the $watch construct is not required e.g:

 

 

2019-09-13_17-45-21.gif

 

Additionally, you can add a filter for example to use some units in the display.  About detail for using a binding filter you can see the topic: “Using Connection Filters for state-based rendering and value formatting”

 

Re: Simulate Live Data in Vuforia Studio using Java Script

Great and thank you!