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

What is the limitation of "Application Parameters"?

SOLVED
dsgnrClarK
Pearl

What is the limitation of "Application Parameters"?

Hi there,

 

I have 2 Thing properties:

  • testJson (Base Type JSON): { "id": 1, "first_name": "Spenser", "last_name": "Cowton", "email": "scowton0@blog.com", "gender": "Male", "ip_address": "60.10.239.62", "Car VIN": "2G4WS52J831457375", "Car make": "Dodge", "Car model": "Ram Van 2500", "Car model year": 1995 }
  • testString (Base Type: string): { "id": 1, "first_name": "Spenser", "last_name": "Cowton", "email": "scowton0@blog.com", "gender": "Male", "ip_address": "60.10.239.62", "Car VIN": "2G4WS52J831457375", "Car make": "Dodge", "Car model": "Ram Van 2500", "Car model year": 1995 }

 

Bindings in Vuforia Studio are:

property widget application parameters
testJson ['label-json'].text testJson
testString ['label-string'].text testString

 

When I console.log $scope.view.wdg['wdg-id'].text and $scope.app.params['params'] respectively.

Widgets can deliver data flawlessly, but Application Parameters do not.

 

console.log($scope.app.params.testJson)

>>> [object object] (type: string)

console.log($scope.app.params.testString)

>>> undefined (type: undefined)

 

So, what's the limitation of Application Parameters? What is the Best Practice of Application Parameters?

Help doesn't provide much help.

https://support.ptc.com/help/vuforia/studio/en/#page/Studio_Help_Center%2FAppAndDevicePropPanel.html

 

Thanks in advance.

 

 

Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions

Re: What is the limitation of "Application Parameters"?

Notes:

Thing Property testJson (Base Type: JSON) result
via Label Widget ['label-json'].text everything works, type Object
via Application Parameters $scope.app.params.testJson become a String "[object Object]", length 15

 

Thing Property testString (Base Type: String) result
via Label Widget ['label-string'].text type String, could work with JSON.parse()
via Application Parameters $scope.app.params.testString Must avoid double quotation mark (") in the Thing property, therefore, JSON.parse() is not feasible. 

 

View solution in original post

8 REPLIES 8

Re: What is the limitation of "Application Parameters"?

Hello Clark,

 

The solution is to parse data from Application Parameter to a know type/object.

Here in your example in a JSON type.

We can find example in these posts in PTC Community :

https://community.ptc.com/t5/Vuforia-Studio/Select-Widget-default-value/m-p/611653

https://community.ptc.com/t5/Vuforia-Studio/How-to-use-List-in-ThingWorx-Studio/td-p/522911

 

Best regards,

Samuel

Re: What is the limitation of "Application Parameters"?

Hi, Samuel

 

Thanks you for replying.

Frankly speaking, the question has been simplified.

 

It is a Thing on Thingworx which has 80 properties (boolean) need to be presented in Vuforia Studio.

Rather than binding 80 Widgets in Vuforia Studio with 80 properties on Thingworx. (update every 3sec)

I use Thingworx Service to generate a JSON (name: allStatus), than bind the allStatus to Vuforia Studio.

 

If allStatus  binds  to a Application Parameters:

>>> [object object] (type: string)

If allStatus  binds  to a Vuforia Studio Label Widget:

>>> everything works

 

In other words, I can get the job done with a Widget, just wondering if it is feasible without Widget.

 

Best Regards,

 

ClarK

Re: What is the limitation of "Application Parameters"?

After doing some test,

A double quotation mark (") is in a Thingworx Thing Property  String would cause Vuforia Studio Application Parameter issue.

 

Therefore, avoid " in a Thingworx Thing Property String when binding to Vuforia Studio Application Parameter is required.

 

Re: What is the limitation of "Application Parameters"?

In some cases, you can adapt the value or check it using the JSON.parse() or JSON.stringify() in the filter section of the binding.

example in the filter:

 

return JSON.parse(value);

 

as it was mentioned in the post :https://community.ptc.com/t5/Vuforia-Studio/How-to-use-List-in-ThingWorx-Studio/m-p/522911#M497

In some case when you are not sure what the value is  - in this case you use some construct like (redudnat check):

 

return JSON.parse(JSON.stringify(value));

 

 

converting first to string and then back to object hoping that this will check/ fix the syntax - of course this should be tested in the particular situation - e.g. 

 

$scope.app.params["ItemList"] = "";
 $scope.app.params["ItemList"] = JSON.parse(JSON.stringify(obj));//check

 

as metioned in https://community.ptc.com/t5/Vuforia-Studio/How-to-create-2D-3D-components-using-Javascript-from-a-a...

... or 

return angular.fromJson(value);

as mentioned in: https://community.ptc.com/t5/Vuforia-Studio/Can-t-use-more-than-one-sequence-animation-in-a-single/m...

Re: What is the limitation of "Application Parameters"?

Hi, @RolandRaytchev 

 

Thanks you for replying.

 

Things are, if Thingworx Thing Property (testJson, Base Type: JSON) is bond to a Vuforia Studio Widget (Label), everything works fine. Data in the Vuforia Studio Widget is Object already, No JSON.parse() needed. Therefore, no need for using Filter.

 

Nevertheless, if the same Thing Property testJson is bond to a Vuforia Studio Application Parameters (nemed testJson), Data become a String "[object Object]", with length 15, not 243. Which means that JSON.parse() couldn't do anything to it.

 

Is it possible to Bind a Thingworx Thing Property (Base Type:JSON) to a Vuforia Studio Application Parameters and still preserve the Data it that Property?

 

Best regards, 

ClarK

 

 

Re: What is the limitation of "Application Parameters"?

Notes:

Thing Property testJson (Base Type: JSON) result
via Label Widget ['label-json'].text everything works, type Object
via Application Parameters $scope.app.params.testJson become a String "[object Object]", length 15

 

Thing Property testString (Base Type: String) result
via Label Widget ['label-string'].text type String, could work with JSON.parse()
via Application Parameters $scope.app.params.testString Must avoid double quotation mark (") in the Thing property, therefore, JSON.parse() is not feasible. 

 

View solution in original post

Re: What is the limitation of "Application Parameters"?

Yes , I could reproduce this issue. Strange. I think this seem to be related that there is some delay when the JSON service is called so that when the parameter is initilized . For example when I test the following:

 

2021-01-22_17-58-16.jpg

 

In this case the issue could be reproduced but  when some times later we click a button (button JS Box will call test() ) This  will set the data to the  parameter - then this works fine. Following sample code:

 

$scope.test=function() {
console.warn($scope.app.params['TESTJSON']);
 $scope.setWidgetProp('textArea-1','text',$scope.app.params['TESTJSON']);
}

 

 

2021-01-22_18-03-12.jpg

So now when we click the button ->  data is passed fine to the applicaiton  parameter test and the parameter has also binding to the widget and the value is passed correctly form the parameter to the widget. Therefore I susspect that this is some issue  based on service delay where the value is not converted and passed  correctly 

So if you want to set a parameter with a JSON data which comes form TWX service -> the following workaround could be use /one possible option :

 

// this function will set the data to the parameter
// the function is called after the view is entered
$scope.init=function() {
  let result=$scope.app.mdl['TestRepository'].svc['testJson'].data;
  console.warn(result)
  $scope.app.params['TESTJSON']=JSON.stringify(result);
  $scope.$applyAsync();
};
//event which will call the function with a delay on start
$scope.$on('$ionicView.afterEnter', function()  {
 
  $timeout(() => {
    $scope.init();
  },500)
})
// this will set manually the value form parameter to widget
$scope.test=function() {
console.warn($scope.app.params['TESTJSON']);
 $scope.setWidgetProp('textArea-1','text',$scope.app.params['TESTJSON']);
}
})

 

Here the values are set with some delay

Re: What is the limitation of "Application Parameters"?

Thanks for replying and confirming the issue.

 

I guess it is easier to Bind Thingworx Thing Property to a Vuforia Studio Widget for further usage.

Even it would be a bit more messier in the Views Panel (with Widgets that bond to Thing Properties).

Announcements
Join an
AR Working Group!

Topics available:
AR/VR for Data Optimization AR/VR for Security and Control AR/VR for Inspection