Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X
Hello Everyone
Good Evening,
I am facing problem in logging properties there are some values which are repeating after I carry out the experience multiple times.
PFA attached image in which arrows are shown on the readings which are repeating when I consume the AR experience on my Ipad on view app for multiple times.
I just want to log the properties which are entered by the user on vuforia view app.
Below is the code I am using to write properties from Vuforia Studio to Thingworx:
I have written 2 services for pass & fail
Vuforia Studio JS Code:
Thanks in Advance.
Solved! Go to Solution.
Hi @Aditya1702
Instead of logging data into the ValueStream. You can use Stream or DataTable (if it is low-frequency data) to store data in Thingworx which will avoid multiple entries.
Please refer here for DataTable services -Data Table Services (ptc.com)
About stream -Streams (ptc.com)
/VR
Did you forget an attachment?
Hi,
Yes I forgot, I am attaching it now.
My purpose is I want to enter records row by row into an infotable.
eg, I have these field definitions in datashape: ID, Name, Status, TimeStamp - I want to enter records for these columns,
Record1: 1, Name1, Pass, 27/03/2024
Record2: 2, Name2, Fail, 27/03/2024
Record3: 3, Name3, Pass, 27/03/2024
Thanks in Advance.
Hi @Aditya1702
How are logging values in Thingworx ?
Are you using Value Stream to do it with log enabled properties ?
/VR
Hi @Velkumar ,
Good Morning,
Yes I am using value stream to log values but I am not sure whether I will achieve the output what I want using value streams.
Thanks in Advance.
Regards,
Aditya Gupta
Hi @Aditya1702
Could you please explain your use case. From where you are getting data and why you have used Value Stream to store data.
Usually, value streams create an entry for each property change. For example: if you have 3 logged properties when all 3 properties changed, the value stream inserts 3 rows (each row for each property change). That is the reason for the duplicated value.
There are multiple ways to overcome this. To overcome this, you can store data in Stream, DataTable or External DB.
/VR
Hi,
Actually Ill explain through an example:
Suppose there are 3 users, So when user1 consumes the experience he records different values for prop1, prop2 & prop3
similarly, user2 records different values for prop1, prop2 & prop3
and user3 records different values for prop1, prop2 & prop3
So I want to store these values as datatable in thingworx for future reference.
Hi @Aditya1702
Instead of logging data into the ValueStream. You can use Stream or DataTable (if it is low-frequency data) to store data in Thingworx which will avoid multiple entries.
Please refer here for DataTable services -Data Table Services (ptc.com)
About stream -Streams (ptc.com)
/VR
Hi,
Can you guide me step by step on how to achieve it?
It would be of great help.
I am taking Vuforia View user input for property values.
Thanks & Best Regards,
Aditya Gupta
Hi @Aditya1702
Considering our sample
1. Create a Datashape with 3 properties
2. Create Stream and select datashape created in Step 1
3. Create a service to insert data into the stream
// Values: INFOTABLE dataShape: ""
let Values = Things["STREAM_NAME"].CreateValues();
Values.field1 = prop1;
Values.field2 = prop2;
Values.field3 = prop3;
Things["STREAM_NAME"].AddStreamEntry({
sourceType: undefined /* STRING */,
values: Values /* INFOTABLE */,
location: undefined /* LOCATION */,
source: undefined /* STRING */,
timestamp: undefined /* DATETIME */,
tags: undefined /* TAGS */,
});
4. Call this service in Vuforia Studio and bind inputs
/VR
Hi @Velkumar ,
Where should the service be written inside the stream or inside a new datatable thing?
Also, what should be kept in output of service?
Hi @Aditya1702
Create service in Stream Thing or any other entity based on your use case
Based on your requirement, if you want to show some status set as STRING or NOTHING
/VR
Hi, @Velkumar ,
I want the output in a table form so, can I keep the output of the service as an Infotable with the corresponding datashape ?
Hi @Aditya1702
Yeah please set it as InfoTable and select datashape
Also update your script :
// Values: INFOTABLE dataShape: ""
let Values = Things["STREAMNAME"].CreateValues();
Values.field1 = prop1;
Values.field2 = prop2;
Values.field3 = prop3;
Things["STREAMNAME"].AddStreamEntry({
sourceType: undefined /* STRING */,
values: Values /* INFOTABLE */,
location: undefined /* LOCATION */,
source: undefined /* STRING */,
timestamp: undefined /* DATETIME */,
tags: undefined /* TAGS */,
});
// result: INFOTABLE dataShape: ""
let result = Things["STREAMNAME"].QueryStreamEntriesWithData({
oldestFirst: undefined /* BOOLEAN */,
maxItems: undefined /* NUMBER {"defaultValue":500} */,
sourceTags: undefined /* TAGS */,
endDate: undefined /* DATETIME */,
query: undefined /* QUERY */,
source: undefined /* STRING */,
startDate: undefined /* DATETIME */,
tags: undefined /* TAGS */
});
/VR
Hi @Velkumar ,
Good Morning,
I have written the service provided by you in a datatable thing but, its throwing an error as:
Error executing service InspectionStep. Message :: Unable To Convert From java.lang.String to NUMBER - See Script Error Log for more details.
I have attached the images of the same.
Thanks & Best Regards,
Aditya Gupta.
Hi @Aditya1702
The issue is you are trying to convert String to Number. Check you inputs for Number datatype wether you are passing any string to it
/VR
Hi @Velkumar ,
I checked it the inputs are proper also, you can see in the screenshots attached (Screenshot(1097).png the inputs from Vuforia View app are reflecting in the properties of ThingWorx (ThingWorx 9.4.1)
You can see in the Screenshot(1098).png it is throwing error when I execute the service but when I manually give the inputs in ThingWorx & then execute the service it is showing some output which you can see in Screenshot(1099).png
Hi @Aditya1702
I don't see any input in your manual execution. Please enter values in your service input and execute it
/VR
Hi @Velkumar ,
I have mentioned the input in service which are coming from Vuforia View app on Ipad.
I have attached image for reference so that yo can see there is no problem on getting input from Ipad.
On execution of service it is still throwing the same error:
ERROR:
Error executing service InspectionStep. Message :: Unable To Convert From java.lang.String to NUMBER - See Script Error Log for more details.
I don't know where am I going wrong.
Thanks & Best Regards,
Aditya Gupta
Hi @Aditya1702
Please fill circled value in Thingworx Composer and execute the service. To check whether it throwing any error
/VR
Hi @Velkumar
No after entering values in the area shown by you it does not throws any error.
I've attached the screenshot of the same below.
Hi @Aditya1702
It means the service working properly. You have to pass proper input from Vuforia Studio to make it work
/VR
Hi @Velkumar ,
Below is the code I have written in Vuforia Studio to take input,
Code:
Hi @Aditya1702
Log parameters in the console and debug it. Sorry it is really difficult for me to debug without Vuforia Studio
/VR
Hi @Velkumar ,
Good Morning,
My concern was, if the ThingWorx properties are reflecting input from Vuforia Studio then why isn't the ThingWorx Service which
we created not working.
Any suggestion you can provide?
Regards,
Aditya Gupta
Hi @Velkumar ,
I am using stream to store values.
It's working but the problem is after every single record I need to manually press the execute button in ThingWorx service to store the data into Stream.
Eg. I capture record1 then need to manually press execute button of ThingWorx InspectionAddData service.
Capture record2 again manually press the execute button in ThingWorx InspectionAddData service.
Capture record3 again manually press the execute button in ThingWorx InspectionAddData service.
Now the problem is, how can I trigger execute button of ThingWorx InspectionAddData Service from Vuforia Studio?
Thanks & Best Regards,
Aditya Gupta.
As the duplicate row has a different timestamp this suggests that either there are other columns in the value stream not shown in the screenshot, and/or that the service setting the values is actually called twice. The timestamps in the screenshot are very close to each other (21ms).
In any posting, please also include per default which TWX version you are running.
Hi Aditya1702,
QueryPropertyHistory service had a some smart logging capability. PF below link https://www.ptc.com/en/support/article/cs226000 and try to understand the possibility before using it.
it will help to get in detail about the queryPropertyHistory service.
Best Regards,
Hareef.Pinjari
thanks for sharing
Hello @Aditya1702,
It looks like you have some responses from some community members. If any of these replies helped you solve your question please mark the appropriate reply as the Accepted Solution.
Of course, if you have more to share on your issue, please let the Community know so other community members can continue to help you.
Thanks,
Community Moderation Team.