Skip to main content
1-Visitor
August 15, 2018
Question

Problems when Query Named Property History on JSON

  • August 15, 2018
  • 1 reply
  • 3799 views

Hi,

 

I have 8 JSON properties on a Thing and each of them representing a big cable of temperature sensors and each 8 of them stores 24 temperature readings. 

Now when I want to query those properties, I see bunch of duplicate rows with different timestamps.

When I looked closer to it, I realized that duplicate rows are because those 8 cables updating themselves in random order, and each time when a cable updates itself, the other cables also getting a time stamp and that causes abnormalities when I QueryNamedPropertyHistory.

 

I dont know what s the optimum solution for querying the history of a JSON parameter, but I need urgent help about this.

 

Screen Shot 2018-08-14 at 6.51.42 PM.png

 

Thanks

1 reply

5-Regular Member
August 15, 2018

I have a couple of questions:

What type of base Thing do the 8 JSON properties belong to, a RemoteThing, or a GenericThing?

How are the JSON data getting updated in ThingWorx?

 

Depending on the answers to the above questions you might want to consider adding some abstraction to your data model. It sounds like you have 1 Thing with 8 properties, and each properties has 24 temperature readings embedded in JSON. Consider making a CableTemplate that has a rawJSON property that gets parsed into 24 temperature reading properties every time rawJSON is updated. Once you have the CableTemplate you can create 8 Things that represent the cables: cable1, cable2, cable3, etc.

mbereket1-VisitorAuthor
1-Visitor
August 15, 2018

Thanks for the reply!

 

Answers:

1. It s a generic Thing, and I use ThingWorx 7.2.6-b76

2. JSON is getting updated via a Service I wrote, in that service I use update property values, I dont do anything different than what I have been doing for other device types, except for the fact that I use JSON property this time, rather than number,string etc. 

 

Since I wrote the whole front-end application to support this structure, I really dont want to make significant data store type change. However if I have to, I have to.

But I believe it should be something simple, why does other json properties gets extra TimeStamp value when I dont update them? that s the question that I am trying to find its answer.

 

I really appreciate any help,

Thanks

5-Regular Member
August 15, 2018

I can not duplicate the issue you are seeing.

 

I created a GenericThing, assigned a ValueStream, and added three JSON properties that are logged. I created 3 different services to set a random value for each of the properties and exercised the services to set properties two and three with the 'Test' button in Composer. When I run the QueryNamedPropertyHistory with the Test button I get the results I expect, no changes to property one.

 

I would look into the service you wrote to be sure it isn't updating all the property values. The timestamps are 50-80 milliseconds apart which seems about right for being triggered by an outside service and not internal.