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

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

How to generate a datachange event for a remotely bound property

khayes1
13-Aquamarine

How to generate a datachange event for a remotely bound property

Hi,

as part of my testing I am trying to generate a property change on a property that has a remote binding to a property on a remote thing. Because the property is remotely bound I am unable to set it via the composer.

 

I have a test utility thing and was hoping to create a service that would generate a server side property change event (I have successfully done this for remote thing events previously). I see that there is the option, but I'm unsure how to use it. I have selected a remote thing and inserted the DataChange event into my service, but there doesn't seem to be any way to set the property name.

 

khayes1_0-1586179001454.png

I have selected a remote thing (KH061) and inserted the DataChange event into my service, but there doesn't seem to be any way to set the property name.

 

var params = {
newValue: undefined /* INFOTABLE */,
oldValue: undefined /* INFOTABLE */
};
Things["KH061"].DataChange(params);

 

 

Presumably the 2 infotables (attached file) match the ones you see when subscribing to a property change? If so is there a defined datashape for that? Also not sure what value toset the Quality parameter to.

 

How would you set the property name? 

 

Thanks

K

 

 
 

 

 

 

 

 

9 REPLIES 9
slangley
23-Emerald II
(To:khayes1)

Hi @khayes1.

 

We're not totally understanding, but we would actually recommend testing with an actual device that better represents your use case, which in this situation appears to be a property push. You can leverage the ThingWorx EMS or another SDK to bind with the Thing for simulating property pushes.

 

Have you worked with the EMS or one of the SDK's?  If not, we can provide the appropriate guide to assist.

 

Regards.

 

--Sharon

khayes1
13-Aquamarine
(To:slangley)

Hi,

thanks for the reply. Sorry it wasn't clear.

I am familiar with the edge server etc. but I'm looking to to mimic a remote property push from the server side.

This is for test purposes only, so that I can test my subscription code without involving a real remote device. The particular scenario I wish to test is difficult to actually replicate on a real device.

 

I have done something similar in the past but with remote events (faults & warnings). I have a test utility thing where I added service  that generates a remote event but it is all done on the server, using snippets on a remote entity's event. 

 

I'm looking to do the same thing for a remote property change. I can see that I can choose a remote entity's data change event from the snippets, but can't see how to configure it for a particular property. It just seems to take 2 infotables as inputs (which appear to be new & old value) but there isn't anything that allows you to say which property the data change event is for.

 

hope that makes a bit more sense.

K

 

Hello @khayes1,

 

I don't want to steal your topic, but we have exactly the same issue, which prevents us from running our unit tests in ThingWorx 8.5.3+. It worked differently in 8.5.1, where we were able to set those remote properties programmatically, but not anymore. Unit tests are confined within ThingWorx, they run unattended and shouldn't depend on external components, such as emulated EDGE devices.

 

To make it work there should be some "testing" mode (platform-wide or entity-wide -- we don't care really), which would enable setting those remote properties and receive DataChange events.

 

@slangley, Is there a chance to file an enhancement request for it, while we're thinking on some workaround?

 

Regards,

Constantine

slangley
23-Emerald II
(To:Constantine)

Hi @Constantine.

 

Enhancement requests are now handled via ThingWorx Ideas.  This provides a mechanism for the community to vote on the requests that are most important to it's members and raise awareness within PTC of the need.

 

Please feel free to use the Ideas forum for posting new ideas and voting on existing ones.

 

Regards.

 

--Sharon

Thanks Sharon, I'll do it.

 

/ Constantine

slangley
23-Emerald II
(To:khayes1)

Hi @khayes1.

 

Did you understand that you can use the EMS to simulate a device for your testing?  The EMS download includes examples of property pushes that can be performed for simulating the values needed for testing.

 

@Constantine, once you create your request on the Ideas page, please post the link here for others to vote on it.

 

Regards.

 

--Sharon

slangley
23-Emerald II
(To:slangley)

Hi @khayes1.

 

If one of the previous responses answered your question, please mark the appropriate response as the Accepted Solution for the benefit of others in the community.

 

Regards.

 

--Sharon

slangley
23-Emerald II
(To:slangley)

Hi @khayes1.

 

Please let us know if one of the previous responses helped you to find a solution.  If so, please mark the appropriate response as the Accepted Solution for the benefit of others on the community.

 

Regards.

 

--Sharon

Hi, 

 

You can't, at least from Server Side Javascript (I don't know if you can do it with a Java extension...). I know it's not the solution, but actually we rely on AnyDataChange not DataChange, and you can simulate AnyDataChange event without problem.

 

Best Regards,

Carles.

Top Tags