Skip to main content
21-Topaz I
November 8, 2019

Hi @ifadeev ,

 

here I attached a small project (attached)  which used similar approach to the mention "Gauge moving indicator" but instead of 3d gauge I used a simple 3d assembly where the arrow is a component used for modelItem  definition:

 

2019-11-08_12-36-38.jpg

Here I used a 2d slider widget to set the app parameter for testing. But I also attached here (it is relevant to my environment only) to a Thing property "DoorAngle" and it worked fine.

I used the following javascript:

 

$scope.setArrowValue = function(val) {
let scaleMin=0
let scaleMax=100
let value=val
if(val < scaleMin) value=scaleMin
if(val >scaleMax) value= scaleMax
 //for angleMin angle in assembly is 90
 //for angleMax angele in assembly is -90 
 let deltaAngle= 180.0*value/(scaleMax-scaleMin) 
 let angleCalc= 90-deltaAngle
 $timeout(function () {
 $scope.$applyAsync(()=>{
// for print in the console need to comment it
 console.log("called $scope.setWidgetProp rz with angleCalc="+angleCalc);
 $scope.setWidgetProp('scaleArrow', 'rz', parseInt(angleCalc));

 
 }); 
},5);
 
};


$scope.$watch("app.params['GAUGEANGLE']", function() {
$scope.setArrowValue( parseInt($scope.app.params['GAUGEANGLE'])) 
})

Then I tested it in the preview:

2019-11-08_12-52-01.jpg

 

I attached the project to this post and hope it could be helpful in your case.

 

9 replies

17-Peridot
November 8, 2019

Hello Ifadeev,

 

As I have understood the original thread and post, it is needed to bind the Property Load1 to the Application Parameter named value.

 

If you have an Application Parameter with another name, in Javascript source code, it is needed to change these lines in the original Javascript function  :

$scope.$watch("app.params['value']", function() {

var rotation = $scope.app.params['value']; //instead of "value", fill in the name of the parameter you want to bind to the indicator

 

Change value to the Application Parameter name.

 

Best regards,

Samuel

Translate
ifadeev1-VisitorAuthor
1-Visitor
November 8, 2019

If I change to

 

$scope.$watch("app.params['Load1']", function() {

var rotation = $scope.app.params['Load1']; //instead of "value", fill in the name of the parameter you want to bind to the indicator

 

that doesn't work.

Translate
17-Peridot
November 8, 2019

Hello,

 

  • What do you mean by it doesn't work ? 
  • Do you an error message in Preview, in Developer tools of Chrome, in Console when running the Experience ?

    Or

  • Do you any error when compiling checking syntax of Javascript function ?

 

Thanks in advance for your details and feedback.

 

Best regards,

Samuel

Translate
21-Topaz I
November 8, 2019

Hi @ifadeev ,

 

here I attached a small project (attached)  which used similar approach to the mention "Gauge moving indicator" but instead of 3d gauge I used a simple 3d assembly where the arrow is a component used for modelItem  definition:

 

2019-11-08_12-36-38.jpg

Here I used a 2d slider widget to set the app parameter for testing. But I also attached here (it is relevant to my environment only) to a Thing property "DoorAngle" and it worked fine.

I used the following javascript&colon;

 

$scope.setArrowValue = function(val) {
let scaleMin=0
let scaleMax=100
let value=val
if(val < scaleMin) value=scaleMin
if(val >scaleMax) value= scaleMax
 //for angleMin angle in assembly is 90
 //for angleMax angele in assembly is -90 
 let deltaAngle= 180.0*value/(scaleMax-scaleMin) 
 let angleCalc= 90-deltaAngle
 $timeout(function () {
 $scope.$applyAsync(()=>{
// for print in the console need to comment it
 console.log("called $scope.setWidgetProp rz with angleCalc="+angleCalc);
 $scope.setWidgetProp('scaleArrow', 'rz', parseInt(angleCalc));

 
 }); 
},5);
 
};


$scope.$watch("app.params['GAUGEANGLE']", function() {
$scope.setArrowValue( parseInt($scope.app.params['GAUGEANGLE'])) 
})

Then I tested it in the preview:

2019-11-08_12-52-01.jpg

 

I attached the project to this post and hope it could be helpful in your case.

 

Translate
ifadeev1-VisitorAuthor
1-Visitor
November 8, 2019

Thank you!

It's great!

Translate