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

Problems when Query Named Property History on JSON

mbereket
3-Visitor

Problems when Query Named Property History on JSON

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

7 REPLIES 7

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.

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

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.

@Rick-Stanley

Thanks for taking time and trying, I just opened up a support ticket for this. 

I do pretty much like what you describe, and yes values are not changing, however, every time I update a JSON property, other JSON properties are also getting a new time stamps which causing duplicate values (with different timestamps) when querying named property history. 

I wish I had a chance to show what I am seeing in thingworx, but if you also work on the support team, maybe we can quickly debug the issue with you? my support case number is: 14513175

Can you demonstrate the issue using services no more complicated than the one below?

 

setJsonProperty.PNG

Hi @Rick-Stanley

 

I just tried what you said, and I couldn't replicate the problem either and that s what I was expecting TW to work in our case too. However, problem continues on our production server right now. 

this is how I update:

 

 

if (f == "ts700")
        {
            var props = devProp.getRow(0);

            //logger.debug("BUFFALO CARD----- "+ card)
            props.rssi = Number(payload.rssi);
            props.lastUpdate = timestamp;
            logger.debug("timestamp: "+timestamp)

            var slotName = 'slot_'+card;
            props[slotName] = payload;

            var lastUpdateName = 'lastUpdate_'+card;
            props[lastUpdateName] = timestamp;

            

            delete props.description;
            delete props.thingTemplate;
            delete props.tags;
            delete props.name;

            result.freq = props.freq;
            devProp.setRow(0, props);
            //logger.debug("new devProp: " + devProp.ToJSON());
            Things[uuid].SetPropertyValues({
                values: devProp
            });
            
            alertCheck();
        }

 

Announcements